|
|
@ -1,15 +1,17 @@
|
|
|
|
import { RefreshIcon } from '@heroicons/react/outline';
|
|
|
|
import { RefreshIcon } from '@heroicons/react/outline';
|
|
|
|
import Router from 'next/router';
|
|
|
|
import { useRouter } from 'next/router';
|
|
|
|
import PR from 'pulltorefreshjs';
|
|
|
|
import PR from 'pulltorefreshjs';
|
|
|
|
import { useEffect } from 'react';
|
|
|
|
import { useEffect } from 'react';
|
|
|
|
import ReactDOMServer from 'react-dom/server';
|
|
|
|
import ReactDOMServer from 'react-dom/server';
|
|
|
|
|
|
|
|
|
|
|
|
const PullToRefresh: React.FC = () => {
|
|
|
|
const PullToRefresh = () => {
|
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
PR.init({
|
|
|
|
PR.init({
|
|
|
|
mainElement: '#pull-to-refresh',
|
|
|
|
mainElement: '#pull-to-refresh',
|
|
|
|
onRefresh() {
|
|
|
|
onRefresh() {
|
|
|
|
Router.reload();
|
|
|
|
router.reload();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
iconArrow: ReactDOMServer.renderToString(
|
|
|
|
iconArrow: ReactDOMServer.renderToString(
|
|
|
|
<div className="p-2">
|
|
|
|
<div className="p-2">
|
|
|
@ -28,11 +30,14 @@ const PullToRefresh: React.FC = () => {
|
|
|
|
instructionsReleaseToRefresh: ReactDOMServer.renderToString(<div />),
|
|
|
|
instructionsReleaseToRefresh: ReactDOMServer.renderToString(<div />),
|
|
|
|
instructionsRefreshing: ReactDOMServer.renderToString(<div />),
|
|
|
|
instructionsRefreshing: ReactDOMServer.renderToString(<div />),
|
|
|
|
distReload: 60,
|
|
|
|
distReload: 60,
|
|
|
|
|
|
|
|
distIgnore: 15,
|
|
|
|
|
|
|
|
shouldPullToRefresh: () =>
|
|
|
|
|
|
|
|
!window.scrollY && document.body.style.overflow !== 'hidden',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return () => {
|
|
|
|
return () => {
|
|
|
|
PR.destroyAll();
|
|
|
|
PR.destroyAll();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}, []);
|
|
|
|
}, [router]);
|
|
|
|
|
|
|
|
|
|
|
|
return <div id="pull-to-refresh"></div>;
|
|
|
|
return <div id="pull-to-refresh"></div>;
|
|
|
|
};
|
|
|
|
};
|
|
|
|