Skip to content

Commit

Permalink
optimized chrome old
Browse files Browse the repository at this point in the history
  • Loading branch information
nghiepdev committed Dec 25, 2017
1 parent 2b815a0 commit ea45331
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
32 changes: 28 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,42 @@
if (CSS.supports('overscroll-behavior-y', 'contain')) {
supportsOverscroll = true;
}
} catch (e) {}

if (supportsOverscroll) {
return (document.body.style.overscrollBehaviorY = 'contain');
} else {
const head = document.head || document.body;
const style = document.createElement('style');
const css = `
::-webkit-scrollbar {
width: 5px;
}
::-webkit-scrollbar-thumb {
border-radius: 5px;
background-color: rgba(0, 0, 0, 0.2);
}
`;

style.type = 'text/css';

if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}

head.appendChild(style);
}

try {
addEventListener('test', null, {
get passive() {
supportsPassive = true;
},
});
} catch (e) {}

if (supportsOverscroll) {
return (document.body.style.overscrollBehaviorY = 'contain');
}

const setTouchStartPoint = event => {
lastTouchY = event.touches[0].clientY;
};
Expand Down
2 changes: 1 addition & 1 deletion index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prevent-pull-refresh",
"version": "1.0.0",
"version": "1.0.1",
"description": "Preventing the pull-to-refresh effect browser on mobile",
"main": "index.min.js",
"scripts": {
Expand Down

0 comments on commit ea45331

Please sign in to comment.