@progressive-development/pd-calendar 0.2.18 → 0.2.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/PdCalendar.js +31 -21
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "progressive development calendar web component",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "author": "PD Progressive Development",
6
- "version": "0.2.18",
6
+ "version": "0.2.20",
7
7
  "main": "index.js",
8
8
  "module": "index.js",
9
9
  "scripts": {
package/src/PdCalendar.js CHANGED
@@ -126,6 +126,8 @@ export class PdCalendar extends LitElement {
126
126
  refDate: { type: Object },
127
127
  selectableDates: { type: Boolean},
128
128
  withYearPopup: { type: Array},
129
+ withWheelNavigation: { type: Boolean},
130
+ withTouchNavigation: { type: Boolean},
129
131
  showSelection: { type: Boolean},
130
132
  hideWeekend: { type: Boolean, reflect: true },
131
133
  prevMonthConstraint: { type: Number },
@@ -463,6 +465,7 @@ export class PdCalendar extends LitElement {
463
465
  new CustomEvent('change-month', {
464
466
  detail: {
465
467
  newDate,
468
+ next: true,
466
469
  },
467
470
  })
468
471
  );
@@ -483,6 +486,7 @@ export class PdCalendar extends LitElement {
483
486
  new CustomEvent('change-month', {
484
487
  detail: {
485
488
  newDate,
489
+ prev: true,
486
490
  },
487
491
  })
488
492
  );
@@ -492,41 +496,47 @@ export class PdCalendar extends LitElement {
492
496
  }
493
497
 
494
498
  // eslint-disable-next-line class-methods-use-this
495
- _wheelEvent(e) {
499
+ _wheelEvent(e) {
500
+
501
+ if (this.withWheelNavigation) {
496
502
 
497
- this._wheelDelta += e.deltaY;
503
+ this._wheelDelta += e.deltaY;
498
504
 
499
- if (this._wheelDelta > 360) {
500
- this._wheelDelta = 0;
501
- this._nextMonth();
502
- }
505
+ if (this._wheelDelta > 360) {
506
+ this._wheelDelta = 0;
507
+ this._nextMonth();
508
+ }
503
509
 
504
- if (this._wheelDelta < -360) {
505
- this._wheelDelta = 0;
506
- this._previousMonth();
507
- }
510
+ if (this._wheelDelta < -360) {
511
+ this._wheelDelta = 0;
512
+ this._previousMonth();
513
+ }
514
+ }
508
515
 
509
516
  e.preventDefault();
510
- e.stopPropagation();
511
-
517
+ e.stopPropagation();
512
518
  }
513
519
 
514
520
  // eslint-disable-next-line class-methods-use-this
515
- _touchStartEvent(e) {
516
- this._wheelDelta = e.changedTouches[0].screenX;
521
+ _touchStartEvent(e) {
522
+ if (this.withTouchNavigation) {
523
+ this._wheelDelta = e.changedTouches[0].screenX;
524
+ }
517
525
  e.stopPropagation();
518
526
  }
519
527
 
520
528
  _touchEndEvent(e) {
521
- const touchEndX = e.changedTouches[0].screenX;
529
+ if (this.withTouchNavigation) {
530
+ const touchEndX = e.changedTouches[0].screenX;
522
531
 
523
- const result = this._wheelDelta - touchEndX;
524
- if (result < (TOUCH_MIN_MOVE * -1)) {
525
- this._previousMonth();
526
- } else if (result > TOUCH_MIN_MOVE) {
527
- this._nextMonth();
532
+ const result = this._wheelDelta - touchEndX;
533
+ if (result < (TOUCH_MIN_MOVE * -1)) {
534
+ this._nextMonth();
535
+ } else if (result > TOUCH_MIN_MOVE) {
536
+ this._previousMonth();
537
+ }
528
538
  }
529
- e.stopPropagation();
539
+ e.stopPropagation();
530
540
  }
531
541
 
532
542
  _initFromDate(date) {