react-simple-pull-to-refresh 1.2.1 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,6 +8,12 @@
8
8
  A Simple Pull-To-Refresh Component for React Application with 0 dependency.
9
9
  Works for Mobile and Desktop.
10
10
 
11
+ ## Contributing
12
+
13
+ ⚠️ I don't have much time to take care of the issues at the moment.
14
+
15
+ 🙏 Any help and contribution is greatly appreciated.
16
+
11
17
  ## Demo
12
18
 
13
19
  [Click here 👍](https://thmsgbrt.github.io/react-simple-pull-to-refresh)
@@ -74,11 +80,15 @@ return (
74
80
  | backgroundColor | string | false | | Apply a backgroundColor |
75
81
  | className | string | false | | |
76
82
 
77
- ## Contributing
83
+ ## Changelog
78
84
 
79
- `npm run dev`
85
+ 1.2.5: Fix event listenter leaks - (From: [@d-s-x](https://github.com/d-s-x))
80
86
 
81
- ## Changelog
87
+ 1.2.4: Fix overscroll on iOS Safari - (From: [@d-s-x](https://github.com/d-s-x))
88
+
89
+ 1.2.3: Add React 17+ as valid peer dependencies - (From: [@Felixmosh](https://github.com/felixmosh))
90
+
91
+ 1.2.2: Remove non-null assertion operators from ref.current + TouchEvent check for Mozilla - (From: [@HamAndRock](https://github.com/HamAndRock))
82
92
 
83
93
  1.2.1: Remove unnecessary z-index
84
94
 
@@ -200,7 +200,7 @@ var PullToRefresh = function (_a) {
200
200
  if (e instanceof MouseEvent) {
201
201
  startY = e.pageY;
202
202
  }
203
- if (e instanceof TouchEvent) {
203
+ if (window.TouchEvent && e instanceof TouchEvent) {
204
204
  startY = e.touches[0].pageY;
205
205
  }
206
206
  currentY = startY;
@@ -218,7 +218,7 @@ var PullToRefresh = function (_a) {
218
218
  if (!isDragging) {
219
219
  return;
220
220
  }
221
- if (e instanceof TouchEvent) {
221
+ if (window.TouchEvent && e instanceof TouchEvent) {
222
222
  currentY = e.touches[0].pageY;
223
223
  }
224
224
  else {
@@ -229,6 +229,9 @@ var PullToRefresh = function (_a) {
229
229
  isDragging = false;
230
230
  return;
231
231
  }
232
+ if (e.cancelable) {
233
+ e.preventDefault();
234
+ }
232
235
  // Limit to trigger refresh has been breached
233
236
  if (currentY - startY >= pullDownThreshold) {
234
237
  isDragging = true;
@@ -266,12 +269,15 @@ var PullToRefresh = function (_a) {
266
269
  currentY = 0;
267
270
  // Container has not been dragged enough, put it back to it's initial state
268
271
  if (!pullToRefreshThresholdBreached) {
269
- pullDownRef.current.style.visibility = 'hidden';
272
+ if (pullDownRef.current)
273
+ pullDownRef.current.style.visibility = 'hidden';
270
274
  initContainer();
271
275
  return;
272
276
  }
273
- childrenRef.current.style.overflow = 'visible';
274
- childrenRef.current.style.transform = "translate(0px, " + pullDownThreshold + "px)";
277
+ if (childrenRef.current) {
278
+ childrenRef.current.style.overflow = 'visible';
279
+ childrenRef.current.style.transform = "translate(0px, " + pullDownThreshold + "px)";
280
+ }
275
281
  onRefresh().then(initContainer).catch(initContainer);
276
282
  };
277
283
  return (React__default.createElement("div", { className: "ptr " + className, style: { backgroundColor: backgroundColor }, ref: containerRef },
@@ -195,7 +195,7 @@ var PullToRefresh = function (_a) {
195
195
  if (e instanceof MouseEvent) {
196
196
  startY = e.pageY;
197
197
  }
198
- if (e instanceof TouchEvent) {
198
+ if (window.TouchEvent && e instanceof TouchEvent) {
199
199
  startY = e.touches[0].pageY;
200
200
  }
201
201
  currentY = startY;
@@ -213,7 +213,7 @@ var PullToRefresh = function (_a) {
213
213
  if (!isDragging) {
214
214
  return;
215
215
  }
216
- if (e instanceof TouchEvent) {
216
+ if (window.TouchEvent && e instanceof TouchEvent) {
217
217
  currentY = e.touches[0].pageY;
218
218
  }
219
219
  else {
@@ -224,6 +224,9 @@ var PullToRefresh = function (_a) {
224
224
  isDragging = false;
225
225
  return;
226
226
  }
227
+ if (e.cancelable) {
228
+ e.preventDefault();
229
+ }
227
230
  // Limit to trigger refresh has been breached
228
231
  if (currentY - startY >= pullDownThreshold) {
229
232
  isDragging = true;
@@ -261,12 +264,15 @@ var PullToRefresh = function (_a) {
261
264
  currentY = 0;
262
265
  // Container has not been dragged enough, put it back to it's initial state
263
266
  if (!pullToRefreshThresholdBreached) {
264
- pullDownRef.current.style.visibility = 'hidden';
267
+ if (pullDownRef.current)
268
+ pullDownRef.current.style.visibility = 'hidden';
265
269
  initContainer();
266
270
  return;
267
271
  }
268
- childrenRef.current.style.overflow = 'visible';
269
- childrenRef.current.style.transform = "translate(0px, " + pullDownThreshold + "px)";
272
+ if (childrenRef.current) {
273
+ childrenRef.current.style.overflow = 'visible';
274
+ childrenRef.current.style.transform = "translate(0px, " + pullDownThreshold + "px)";
275
+ }
270
276
  onRefresh().then(initContainer).catch(initContainer);
271
277
  };
272
278
  return (React.createElement("div", { className: "ptr " + className, style: { backgroundColor: backgroundColor }, ref: containerRef },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-simple-pull-to-refresh",
3
- "version": "1.2.1",
3
+ "version": "1.2.5",
4
4
  "description": "A Simple Pull To Refresh Component for React Application",
5
5
  "main": "build/index.cjs.js",
6
6
  "module": "build/index.esm.js",
@@ -40,8 +40,8 @@
40
40
  "typescript": "3.7.5"
41
41
  },
42
42
  "peerDependencies": {
43
- "react": "^16.10.2",
44
- "react-dom": "^16.10.2"
43
+ "react": "^16.10.2 || ^17.0.0",
44
+ "react-dom": "^16.10.2 || ^17.0.0"
45
45
  },
46
46
  "files": [
47
47
  "build"