@progressive-development/pd-calendar 0.2.17 → 0.2.19

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 +2 -2
  2. package/src/PdCalendar.js +29 -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.17",
6
+ "version": "0.2.19",
7
7
  "main": "index.js",
8
8
  "module": "index.js",
9
9
  "scripts": {
@@ -33,7 +33,7 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@lit/localize": "^0.12.1",
36
- "@progressive-development/pd-icon": "^0.1.22",
36
+ "@progressive-development/pd-icon": "^0.1.23",
37
37
  "@progressive-development/pd-shared-styles": "0.1.1",
38
38
  "fecha": "^4.2.3",
39
39
  "lit": "^2.8.0"
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 },
@@ -492,41 +494,47 @@ export class PdCalendar extends LitElement {
492
494
  }
493
495
 
494
496
  // eslint-disable-next-line class-methods-use-this
495
- _wheelEvent(e) {
497
+ _wheelEvent(e) {
498
+
499
+ if (this.withWheelNavigation) {
496
500
 
497
- this._wheelDelta += e.deltaY;
501
+ this._wheelDelta += e.deltaY;
498
502
 
499
- if (this._wheelDelta > 360) {
500
- this._wheelDelta = 0;
501
- this._nextMonth();
502
- }
503
+ if (this._wheelDelta > 360) {
504
+ this._wheelDelta = 0;
505
+ this._nextMonth();
506
+ }
503
507
 
504
- if (this._wheelDelta < -360) {
505
- this._wheelDelta = 0;
506
- this._previousMonth();
507
- }
508
+ if (this._wheelDelta < -360) {
509
+ this._wheelDelta = 0;
510
+ this._previousMonth();
511
+ }
512
+ }
508
513
 
509
514
  e.preventDefault();
510
- e.stopPropagation();
511
-
515
+ e.stopPropagation();
512
516
  }
513
517
 
514
518
  // eslint-disable-next-line class-methods-use-this
515
- _touchStartEvent(e) {
516
- this._wheelDelta = e.changedTouches[0].screenX;
519
+ _touchStartEvent(e) {
520
+ if (this.withTouchNavigation) {
521
+ this._wheelDelta = e.changedTouches[0].screenX;
522
+ }
517
523
  e.stopPropagation();
518
524
  }
519
525
 
520
526
  _touchEndEvent(e) {
521
- const touchEndX = e.changedTouches[0].screenX;
527
+ if (this.withTouchNavigation) {
528
+ const touchEndX = e.changedTouches[0].screenX;
522
529
 
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();
530
+ const result = this._wheelDelta - touchEndX;
531
+ if (result < (TOUCH_MIN_MOVE * -1)) {
532
+ this._nextMonth();
533
+ } else if (result > TOUCH_MIN_MOVE) {
534
+ this._previousMonth();
535
+ }
528
536
  }
529
- e.stopPropagation();
537
+ e.stopPropagation();
530
538
  }
531
539
 
532
540
  _initFromDate(date) {