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

Commit 39625bc

Browse files
committed
remove babel
1 parent 043fd67 commit 39625bc

File tree

5 files changed

+35
-1920
lines changed

5 files changed

+35
-1920
lines changed

.babelrc

Lines changed: 0 additions & 8 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Preventing the pull-to-refresh effect browser on mobile
44

55
[![NPM version](https://img.shields.io/npm/v/prevent-pull-refresh.svg)](https://www.npmjs.com/package/prevent-pull-refresh)
6-
[![NPM monthly download](https://img.shields.io/npm/dm/prevent-pull-refresh.svg)](https://www.npmjs.com/package/prevent-pull-refresh)
6+
[![NPM yearly download](https://img.shields.io/npm/dy/prevent-pull-refresh.svg)](https://www.npmjs.com/package/prevent-pull-refresh)
77

88
## Document
99

@@ -32,4 +32,4 @@ or
3232

3333
## License
3434

35-
MIT © [Nghiệp](http://nghiepit.pro)
35+
MIT © [Nghiep](http://nghiepit.dev)

index.js

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
(() => {
2-
const isChrome = window.chrome || navigator.userAgent.match('CriOS');
3-
const isTouch = 'ontouchstart' in document.documentElement;
1+
'use strict';
2+
3+
(function() {
4+
var isChrome = window.chrome || navigator.userAgent.match('CriOS');
5+
var isTouch = 'ontouchstart' in document.documentElement;
46

57
if (!isChrome || !isTouch) {
68
return;
79
}
810

9-
let supportsOverscroll = false;
10-
let supportsPassive = false;
11-
let lastTouchY = 0;
12-
let maybePrevent = false;
11+
var supportsOverscroll = false;
12+
var supportsPassive = false;
13+
var lastTouchY = 0;
14+
var maybePrevent = false;
1315

1416
try {
1517
if (CSS.supports('overscroll-behavior-y', 'contain')) {
@@ -20,21 +22,10 @@
2022
if (supportsOverscroll) {
2123
return (document.body.style.overscrollBehaviorY = 'contain');
2224
} 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-
body {
34-
-webkit-overflow-scrolling: auto!important;
35-
}
36-
`;
37-
25+
var head = document.head || document.body;
26+
var style = document.createElement('style');
27+
var css =
28+
'\n ::-webkit-scrollbar {\n width: 5px;\n }\n ::-webkit-scrollbar-thumb {\n border-radius: 5px;\n background-color: rgba(0, 0, 0, 0.2);\n }\n body {\n -webkit-overflow-scrolling: auto!important;\n }\n ';
3829
style.type = 'text/css';
3930

4031
if (style.styleSheet) {
@@ -47,35 +38,34 @@
4738
}
4839

4940
try {
50-
addEventListener('test', null, {
41+
window.addEventListener('test', null, {
5142
get passive() {
5243
supportsPassive = true;
5344
},
5445
});
5546
} catch (e) {}
5647

57-
const setTouchStartPoint = event => {
48+
var setTouchStartPoint = function setTouchStartPoint(event) {
5849
lastTouchY = event.touches[0].clientY;
5950
};
6051

61-
const isScrollingUp = event => {
62-
const touchY = event.touches[0].clientY;
63-
const touchYDelta = touchY - lastTouchY;
64-
52+
var isScrollingUp = function isScrollingUp(event) {
53+
var touchY = event.touches[0].clientY;
54+
var touchYDelta = touchY - lastTouchY;
6555
lastTouchY = touchY;
66-
6756
return touchYDelta > 0;
6857
};
6958

70-
const touchstartHandler = event => {
59+
var touchstartHandler = function touchstartHandler(event) {
7160
if (event.touches.length !== 1) return;
7261
setTouchStartPoint(event);
7362
maybePrevent = window.pageYOffset === 0;
7463
};
7564

76-
const touchmoveHandler = event => {
65+
var touchmoveHandler = function touchmoveHandler(event) {
7766
if (maybePrevent) {
7867
maybePrevent = false;
68+
7969
if (isScrollingUp(event)) {
8070
return event.preventDefault();
8171
}
@@ -85,12 +75,19 @@
8575
document.addEventListener(
8676
'touchstart',
8777
touchstartHandler,
88-
supportsPassive ? {passive: true} : false,
78+
supportsPassive
79+
? {
80+
passive: true,
81+
}
82+
: false,
8983
);
90-
9184
document.addEventListener(
9285
'touchmove',
9386
touchmoveHandler,
94-
supportsPassive ? {passive: false} : false,
87+
supportsPassive
88+
? {
89+
passive: false,
90+
}
91+
: false,
9592
);
9693
})();

package.json

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,10 @@
33
"version": "1.0.4",
44
"description": "Preventing the pull-to-refresh effect browser on mobile",
55
"files": [
6-
"index.min.js",
7-
"index.min.js.map",
86
"LICENCE",
97
"README.md"
108
],
11-
"main": "index.min.js",
12-
"scripts": {
13-
"build": "cross-env NODE_ENV=production babel index.js -o index.min.js -s",
14-
"prepublish": "npm run build"
15-
},
16-
"devDependencies": {
17-
"babel-cli": "^6.26.0",
18-
"babel-preset-env": "^1.7.0",
19-
"babel-preset-minify": "^0.5.0",
20-
"cross-env": "^5.2.0"
21-
},
9+
"main": "index.js",
2210
"homepage": "https://github.com/nghiepit/prevent-pull-refresh",
2311
"repository": "https://github.com/nghiepit/prevent-pull-refresh",
2412
"keywords": [
@@ -31,6 +19,6 @@
3119
"scroll",
3220
"overscroll"
3321
],
34-
"author": "Nghiep <me@nghiepit.pro>",
22+
"author": "Nghiep <me@nghiepit.dev>",
3523
"license": "MIT"
3624
}

0 commit comments

Comments
 (0)