Skip to content

Commit

Permalink
test: speed up the keyboard tests (#3798)
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen authored and vaadin-bot committed May 6, 2022
1 parent 6f402bb commit 63e29f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/date-picker/src/vaadin-date-picker-overlay-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po

static get properties() {
return {
scrollDuration: {
type: Number,
default: 300,
},

/**
* The value for this element.
*/
Expand Down Expand Up @@ -524,16 +529,20 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
return (-c / 2) * (t * (t - 2) - 1) + b;
};

var duration = animate ? 300 : 0;
var start = 0;
var initialPosition = this.$.monthScroller.position;

var smoothScroll = (timestamp) => {
start = start || timestamp;
var currentTime = timestamp - start;

if (currentTime < duration) {
var currentPos = easingFunction(currentTime, initialPosition, this._targetPosition - initialPosition, duration);
if (currentTime < this.scrollDuration) {
var currentPos = easingFunction(
currentTime,
initialPosition,
this._targetPosition - initialPosition,
this.scrollDuration,
);
this.$.monthScroller.position = currentPos;
window.requestAnimationFrame(smoothScroll);
} else {
Expand Down
1 change: 1 addition & 0 deletions packages/date-picker/test/keyboard-navigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ import { getDefaultI18n, getFocusedCell, getOverlayContent, open, waitForScrollT
overlay = fixtureSync(`
<vaadin-date-picker-overlay-content
style="position: absolute; top: 0"
scroll-duration="0"
></vaadin-date-picker-overlay-content>`);
overlay.i18n = getDefaultI18n();

Expand Down

0 comments on commit 63e29f7

Please sign in to comment.