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

Commit ea45331

Browse files
committed
optimized chrome old
1 parent 2b815a0 commit ea45331

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

index.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,42 @@
1515
if (CSS.supports('overscroll-behavior-y', 'contain')) {
1616
supportsOverscroll = true;
1717
}
18+
} catch (e) {}
19+
20+
if (supportsOverscroll) {
21+
return (document.body.style.overscrollBehaviorY = 'contain');
22+
} else {
23+
const head = document.head || document.body;
24+
const style = document.createElement('style');
25+
const css = `
26+
::-webkit-scrollbar {
27+
width: 5px;
28+
}
29+
::-webkit-scrollbar-thumb {
30+
border-radius: 5px;
31+
background-color: rgba(0, 0, 0, 0.2);
32+
}
33+
`;
34+
35+
style.type = 'text/css';
36+
37+
if (style.styleSheet) {
38+
style.styleSheet.cssText = css;
39+
} else {
40+
style.appendChild(document.createTextNode(css));
41+
}
42+
43+
head.appendChild(style);
44+
}
1845

46+
try {
1947
addEventListener('test', null, {
2048
get passive() {
2149
supportsPassive = true;
2250
},
2351
});
2452
} catch (e) {}
2553

26-
if (supportsOverscroll) {
27-
return (document.body.style.overscrollBehaviorY = 'contain');
28-
}
29-
3054
const setTouchStartPoint = event => {
3155
lastTouchY = event.touches[0].clientY;
3256
};

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": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Preventing the pull-to-refresh effect browser on mobile",
55
"main": "index.min.js",
66
"scripts": {

0 commit comments

Comments
 (0)