@progressive-development/pd-calendar 0.2.18 → 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.
- package/package.json +1 -1
- package/src/PdCalendar.js +29 -21
package/package.json
CHANGED
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
|
-
|
|
501
|
+
this._wheelDelta += e.deltaY;
|
|
498
502
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
+
if (this._wheelDelta > 360) {
|
|
504
|
+
this._wheelDelta = 0;
|
|
505
|
+
this._nextMonth();
|
|
506
|
+
}
|
|
503
507
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
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.
|
|
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
|
-
|
|
527
|
+
if (this.withTouchNavigation) {
|
|
528
|
+
const touchEndX = e.changedTouches[0].screenX;
|
|
522
529
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
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) {
|