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

fix: rollback JS event passive mode in SlickGrid #778

Merged
merged 1 commit into from
May 19, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions slick.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,32 +624,6 @@
return Object.entries(obj).length === 0;
}

/**
* Check if `passive` option is supported when adding event listener, follows detection provided in MDN:
* https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#safely_detecting_option_support
*/
function passiveSupported() {
let passiveSupported = false;

try {
const options = {
get passive() {
passiveSupported = true;
return false;
},
};
window.addEventListener('test', null, options);
window.removeEventListener('test', null, options);
} catch (err) {
passiveSupported = false;
}
return passiveSupported;
}

function enablePassiveWhenSupported() {
return passiveSupported() ? { passive: true } : false
}

function noop() { }

function offset(el) {
Expand Down Expand Up @@ -917,8 +891,6 @@
"calculateAvailableSpace": calculateAvailableSpace,
"createDomElement": createDomElement,
"emptyElement": emptyElement,
"passiveSupported": passiveSupported,
"enablePassiveWhenSupported": enablePassiveWhenSupported,
"innerSize": innerSize,
"isEmptyObject": isEmptyObject,
"noop": noop,
Expand Down
8 changes: 4 additions & 4 deletions slick.interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
};

if (containerElement) {
containerElement.addEventListener('mousedown', userPressed, Slick.Utils.enablePassiveWhenSupported());
containerElement.addEventListener('touchstart', userPressed, Slick.Utils.enablePassiveWhenSupported());
containerElement.addEventListener('mousedown', userPressed);
containerElement.addEventListener('touchstart', userPressed);
}

function executeDragCallbackWhenDefined(callback, e, dd) {
Expand All @@ -51,8 +51,8 @@

function destroy() {
if (containerElement) {
containerElement.removeEventListener('mousedown', userPressed, Slick.Utils.enablePassiveWhenSupported());
containerElement.removeEventListener('touchstart', userPressed, Slick.Utils.enablePassiveWhenSupported());
containerElement.removeEventListener('mousedown', userPressed);
containerElement.removeEventListener('touchstart', userPressed);
}
}

Expand Down