Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: speed up the keyboard tests #3798

Merged
merged 1 commit into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is an internal component, so I thought it doesn't matter whether the property should start with _ or not.

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;
tomivirkki marked this conversation as resolved.
Show resolved Hide resolved
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