Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit 88bd117

Browse files
committed
passive: true
1 parent 338b6ab commit 88bd117

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

index.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
(() => {
22
let lastTouchY = 0;
33
let maybePrevent = false;
4+
let supportsPassive = false;
5+
6+
try {
7+
addEventListener('test', null, {
8+
get passive() {
9+
supportsPassive = true;
10+
},
11+
});
12+
} catch (e) {}
413

514
const setTouchStartPoint = event => {
615
lastTouchY = event.touches[0].clientY;
@@ -30,6 +39,11 @@
3039
}
3140
};
3241

33-
document.addEventListener('touchstart', touchstartHandler);
42+
document.addEventListener(
43+
'touchstart',
44+
touchstartHandler,
45+
supportsPassive ? { passive: true } : false
46+
);
47+
3448
document.addEventListener('touchmove', touchmoveHandler);
3549
})();

index.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "prevent-pull-refresh",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "Preventing the pull-to-refresh effect browser on mobile",
55
"main": "index.min.js",
66
"scripts": {

0 commit comments

Comments
 (0)