@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.
- package/package.json +1 -1
- package/src/PdCalendar.js +31 -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 },
|
|
@@ -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
|
-
|
|
503
|
+
this._wheelDelta += e.deltaY;
|
|
498
504
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
505
|
+
if (this._wheelDelta > 360) {
|
|
506
|
+
this._wheelDelta = 0;
|
|
507
|
+
this._nextMonth();
|
|
508
|
+
}
|
|
503
509
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
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.
|
|
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
|
-
|
|
529
|
+
if (this.withTouchNavigation) {
|
|
530
|
+
const touchEndX = e.changedTouches[0].screenX;
|
|
522
531
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
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) {
|