Skip to content

Commit 22ff5a4

Browse files
authored
refactor!: remove swipe gesture for toggling year scroller (#9362)
1 parent be6b001 commit 22ff5a4

File tree

6 files changed

+1
-103
lines changed

6 files changed

+1
-103
lines changed

packages/date-picker/src/vaadin-date-picker-overlay-content-mixin.js

Lines changed: 1 addition & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
import { timeOut } from '@vaadin/component-base/src/async.js';
77
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
8-
import { addListener, setTouchAction } from '@vaadin/component-base/src/gestures.js';
8+
import { addListener } from '@vaadin/component-base/src/gestures.js';
99
import { MediaQueryController } from '@vaadin/component-base/src/media-query-controller.js';
1010
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
1111
import {
@@ -75,10 +75,6 @@ export const DatePickerOverlayContentMixin = (superClass) =>
7575
value: '(min-width: 375px)',
7676
},
7777

78-
_yearScrollerWidth: {
79-
value: 50,
80-
},
81-
8278
i18n: {
8379
type: Object,
8480
},
@@ -176,9 +172,6 @@ export const DatePickerOverlayContentMixin = (superClass) =>
176172

177173
/** @protected */
178174
_addListeners() {
179-
setTouchAction(this.$.scrollers, 'pan-y');
180-
181-
addListener(this.$.scrollers, 'track', this._track.bind(this));
182175
addListener(this.shadowRoot.querySelector('[part="clear-button"]'), 'tap', this._clear.bind(this));
183176
addListener(this.shadowRoot.querySelector('[part="toggle-button"]'), 'tap', this._cancel.bind(this));
184177
addListener(
@@ -226,7 +219,6 @@ export const DatePickerOverlayContentMixin = (superClass) =>
226219

227220
reset() {
228221
this._closeYearScroller();
229-
this._toggleAnimateClass(true);
230222
}
231223

232224
/**
@@ -643,82 +635,14 @@ export const DatePickerOverlayContentMixin = (superClass) =>
643635
window.requestAnimationFrame(smoothScroll);
644636
}
645637

646-
/** @private */
647-
_limit(value, range) {
648-
return Math.min(range.max, Math.max(range.min, value));
649-
}
650-
651-
/** @private */
652-
_handleTrack(e) {
653-
// Check if horizontal movement threshold (dx) not exceeded or
654-
// scrolling fast vertically (ddy).
655-
if (Math.abs(e.detail.dx) < 10 || Math.abs(e.detail.ddy) > 10) {
656-
return;
657-
}
658-
659-
// If we're flinging quickly -> start animating already.
660-
if (Math.abs(e.detail.ddx) > this._yearScrollerWidth / 3) {
661-
this._toggleAnimateClass(true);
662-
}
663-
664-
const newTranslateX = this._translateX + e.detail.ddx;
665-
this._translateX = this._limit(newTranslateX, {
666-
min: 0,
667-
max: this._yearScrollerWidth,
668-
});
669-
}
670-
671-
/** @private */
672-
_track(e) {
673-
if (this._desktopMode) {
674-
// No need to track for swipe gestures on desktop.
675-
return;
676-
}
677-
678-
switch (e.detail.state) {
679-
case 'start':
680-
this._toggleAnimateClass(false);
681-
break;
682-
case 'track':
683-
this._handleTrack(e);
684-
break;
685-
case 'end':
686-
this._toggleAnimateClass(true);
687-
if (this._translateX >= this._yearScrollerWidth / 2) {
688-
this._closeYearScroller();
689-
} else {
690-
this._openYearScroller();
691-
}
692-
break;
693-
default:
694-
break;
695-
}
696-
}
697-
698-
/** @private */
699-
_toggleAnimateClass(enable) {
700-
if (enable) {
701-
this.classList.add('animate');
702-
} else {
703-
this.classList.remove('animate');
704-
}
705-
}
706-
707638
/** @private */
708639
_toggleYearScroller() {
709640
this.toggleAttribute('years-visible');
710641
}
711642

712-
/** @private */
713-
_openYearScroller() {
714-
this._translateX = 0;
715-
this.setAttribute('years-visible', '');
716-
}
717-
718643
/** @private */
719644
_closeYearScroller() {
720645
this.removeAttribute('years-visible');
721-
this._translateX = this._yearScrollerWidth;
722646
}
723647

724648
/** @private */

packages/date-picker/src/vaadin-date-picker-overlay-content-styles.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ export const overlayContentStyles = css`
6565
visibility: visible;
6666
}
6767
68-
:host(.animate) ::slotted([slot='months']),
69-
:host(.animate) ::slotted([slot='years']) {
70-
transition: all 200ms;
71-
}
72-
7368
[part='toolbar'] {
7469
display: flex;
7570
grid-area: toolbar;

packages/date-picker/test/dom/__snapshots__/date-picker.test.snap.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ snapshots["vaadin-date-picker host opened overlay"] =
295295
top-aligned=""
296296
>
297297
<vaadin-date-picker-overlay-content
298-
class="animate"
299298
desktop=""
300299
role="dialog"
301300
>
@@ -458,7 +457,6 @@ snapshots["vaadin-date-picker host opened overlay class"] =
458457
top-aligned=""
459458
>
460459
<vaadin-date-picker-overlay-content
461-
class="animate"
462460
desktop=""
463461
role="dialog"
464462
>
@@ -621,7 +619,6 @@ snapshots["vaadin-date-picker host opened overlay theme"] =
621619
top-aligned=""
622620
>
623621
<vaadin-date-picker-overlay-content
624-
class="animate"
625622
desktop=""
626623
role="dialog"
627624
theme="custom"

packages/date-picker/test/visual/common.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,6 @@ registerStyles(
2727
`,
2828
);
2929

30-
registerStyles(
31-
'vaadin-date-picker-overlay-content',
32-
css`
33-
/* Disable animation */
34-
::slotted([slot='years']),
35-
::slotted([slot='months']) {
36-
animation: none !important;
37-
transition: none !important;
38-
}
39-
`,
40-
);
41-
4230
/* Stop focused day animation */
4331
registerStyles(
4432
'vaadin-month-calendar',

packages/date-time-picker/test/dom/__snapshots__/date-time-picker.test.snap.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,6 @@ snapshots["vaadin-date-time-picker host overlay class date-picker"] =
533533
top-aligned=""
534534
>
535535
<vaadin-date-picker-overlay-content
536-
class="animate"
537536
desktop=""
538537
role="dialog"
539538
>

packages/vaadin-lumo-styles/src/components/date-picker-overlay-content.css

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@
9494
visibility: visible;
9595
}
9696

97-
:host(.animate) ::slotted([slot='months']),
98-
:host(.animate) ::slotted([slot='years']) {
99-
transition: all 200ms;
100-
}
101-
10297
/* Year scroller position indicator */
10398
::slotted([slot='years'])::before {
10499
border: none;

0 commit comments

Comments
 (0)