From 05e62ffebcacb4aa5611f58124ee181b4dc71bfe Mon Sep 17 00:00:00 2001 From: johnsonsu Date: Wed, 24 May 2023 14:52:45 -0400 Subject: [PATCH 1/3] Use optional chaining instead of non-null assert --- src/components/pull-to-refresh.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/pull-to-refresh.tsx b/src/components/pull-to-refresh.tsx index f8dd21e..1518e41 100644 --- a/src/components/pull-to-refresh.tsx +++ b/src/components/pull-to-refresh.tsx @@ -176,22 +176,22 @@ const PullToRefresh: React.FC = ({ if (e.cancelable) { e.preventDefault(); } - + const yDistanceMoved = Math.min((currentY - startY) / resistance, maxPullDownDistance); // Limit to trigger refresh has been breached if (yDistanceMoved >= pullDownThreshold) { isDragging = true; pullToRefreshThresholdBreached = true; - containerRef.current!.classList.remove('ptr--dragging'); - containerRef.current!.classList.add('ptr--pull-down-treshold-breached'); + containerRef.current?.classList.remove('ptr--dragging'); + containerRef.current?.classList.add('ptr--pull-down-treshold-breached'); } // maxPullDownDistance breached, stop the animation if (yDistanceMoved >= maxPullDownDistance) { return; } - pullDownRef.current!.style.opacity = ((yDistanceMoved) / 65).toString(); + pullDownRef.current!.style.opacity = (yDistanceMoved / 65).toString(); childrenRef.current!.style.overflow = 'visible'; childrenRef.current!.style.transform = `translate(0px, ${yDistanceMoved}px)`; pullDownRef.current!.style.visibility = 'visible'; @@ -207,7 +207,7 @@ const PullToRefresh: React.FC = ({ */ if (canFetchMore && getScrollToBottomValue() < fetchMoreThreshold && onFetchMore) { fetchMoreTresholdBreached = true; - containerRef.current!.classList.add('ptr--fetch-more-treshold-breached'); + containerRef.current?.classList.add('ptr--fetch-more-treshold-breached'); onFetchMore().then(initContainer).catch(initContainer); } }; From 922dbabab25ede4f34776a1ee1fe68f9a13fde28 Mon Sep 17 00:00:00 2001 From: johnsonsu Date: Fri, 9 Jun 2023 11:53:44 -0400 Subject: [PATCH 2/3] Get ready to publish Github package --- .npmrc | 1 + docs/asset-manifest.json | 6 +- docs/index.html | 2 +- docs/static/js/main.8604e0fc.js | 3 + docs/static/js/main.8604e0fc.js.LICENSE.txt | 39 + docs/static/js/main.8604e0fc.js.map | 1 + package-lock.json | 3854 ++-- package.json | 10 +- playground/package-lock.json | 18081 +++++++++++------- playground/src/pull-to-refresh/index.js | 15 +- playground/yarn.lock | 3183 +-- src/components/pull-to-refresh.tsx | 4 +- 12 files changed, 15896 insertions(+), 9303 deletions(-) create mode 100644 .npmrc create mode 100644 docs/static/js/main.8604e0fc.js create mode 100644 docs/static/js/main.8604e0fc.js.LICENSE.txt create mode 100644 docs/static/js/main.8604e0fc.js.map diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..a839735 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +@johnsonsu/react-simple-pull-to-refresh:registry=https://npm.pkg.github.com diff --git a/docs/asset-manifest.json b/docs/asset-manifest.json index fd3b924..eef87e8 100644 --- a/docs/asset-manifest.json +++ b/docs/asset-manifest.json @@ -1,13 +1,13 @@ { "files": { "main.css": "/react-simple-pull-to-refresh/static/css/main.0388a0eb.css", - "main.js": "/react-simple-pull-to-refresh/static/js/main.7c3992f0.js", + "main.js": "/react-simple-pull-to-refresh/static/js/main.8604e0fc.js", "index.html": "/react-simple-pull-to-refresh/index.html", "main.0388a0eb.css.map": "/react-simple-pull-to-refresh/static/css/main.0388a0eb.css.map", - "main.7c3992f0.js.map": "/react-simple-pull-to-refresh/static/js/main.7c3992f0.js.map" + "main.8604e0fc.js.map": "/react-simple-pull-to-refresh/static/js/main.8604e0fc.js.map" }, "entrypoints": [ "static/css/main.0388a0eb.css", - "static/js/main.7c3992f0.js" + "static/js/main.8604e0fc.js" ] } \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 2201bee..713c65c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1 +1 @@ -React App
\ No newline at end of file +React App
\ No newline at end of file diff --git a/docs/static/js/main.8604e0fc.js b/docs/static/js/main.8604e0fc.js new file mode 100644 index 0000000..427a150 --- /dev/null +++ b/docs/static/js/main.8604e0fc.js @@ -0,0 +1,3 @@ +/*! For license information please see main.8604e0fc.js.LICENSE.txt */ +!function(){"use strict";var e={463:function(e,n,t){var r=t(791),l=t(296);function a(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,t=1;t