ps99-api 2.7.1 → 2.8.0
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.
|
@@ -13,16 +13,18 @@ const App: React.FC = () => {
|
|
|
13
13
|
return (
|
|
14
14
|
<Router>
|
|
15
15
|
<ScrollProvider>
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<Route
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
<ScrollProvider>
|
|
17
|
+
<Header />
|
|
18
|
+
<Routes>
|
|
19
|
+
<Route path="/" element={<HomePage />} />
|
|
20
|
+
<Route path="/collections" element={<CollectionsIndex />} />
|
|
21
|
+
<Route element={<CollectionsLayout />}>
|
|
22
|
+
<Route path="/collections/:collectionName" element={<CollectionConfigIndex />} />
|
|
23
|
+
<Route path="/collections/:collectionName/:configName" element={<DynamicCollectionConfigData />} />
|
|
24
|
+
</Route>
|
|
25
|
+
</Routes>
|
|
26
|
+
<Footer />
|
|
27
|
+
</ScrollProvider>
|
|
26
28
|
</ScrollProvider>
|
|
27
29
|
</Router>
|
|
28
30
|
);
|
|
@@ -497,7 +497,8 @@ const CollectionConfigIndex: React.FC<CollectionConfigIndexProps> = () => {
|
|
|
497
497
|
onRefresh: async () => {
|
|
498
498
|
// Simple reload to fetch new data
|
|
499
499
|
window.location.reload();
|
|
500
|
-
}
|
|
500
|
+
},
|
|
501
|
+
disabled: !isMobile
|
|
501
502
|
});
|
|
502
503
|
|
|
503
504
|
// Update scroll top for PTR
|
|
@@ -6,6 +6,7 @@ import { FixedSizeGrid, FixedSizeList } from "./ReactWindowMock";
|
|
|
6
6
|
import AutoSizer from "./AutoSizer";
|
|
7
7
|
import { useScrollPersistence } from "../context/ScrollContext";
|
|
8
8
|
import { useCollapsibleHeader } from '../hooks/useCollapsibleHeader';
|
|
9
|
+
import { usePullToRefresh } from '../hooks/usePullToRefresh';
|
|
9
10
|
|
|
10
11
|
const FixedSizeGridAny = FixedSizeGrid;
|
|
11
12
|
const FixedSizeListAny = FixedSizeList;
|
|
@@ -138,8 +139,24 @@ const CollectionsIndex: React.FC = () => {
|
|
|
138
139
|
const [searchTerm, setSearchTerm] = useState("");
|
|
139
140
|
const [windowWidth, setWindowWidth] = useState(window.innerWidth);
|
|
140
141
|
const [viewMode, setViewMode] = useState<'grid' | 'list'>('grid');
|
|
142
|
+
const isMobile = windowWidth < 768; // Defined before use
|
|
141
143
|
const { showHeader, handleScroll, scrollRef, headerRef, headerHeight, contentPadding } = useCollapsibleHeader({ deps: [collections] });
|
|
142
144
|
|
|
145
|
+
// Pull To Refresh Logic
|
|
146
|
+
|
|
147
|
+
// Pull To Refresh Logic
|
|
148
|
+
const { isRefreshing, pullDistance, onTouchStart, onTouchMove, onTouchEnd, updateScrollTop, isDragging } = usePullToRefresh({
|
|
149
|
+
onRefresh: async () => {
|
|
150
|
+
window.location.reload();
|
|
151
|
+
},
|
|
152
|
+
disabled: !isMobile
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
const onScroll = (scrollInfo: { scrollOffset?: number, scrollTop?: number, scrollHeight?: number, clientHeight?: number }) => {
|
|
156
|
+
handleScroll(scrollInfo);
|
|
157
|
+
updateScrollTop(scrollInfo.scrollTop ?? scrollInfo.scrollOffset ?? 0);
|
|
158
|
+
};
|
|
159
|
+
|
|
143
160
|
useEffect(() => {
|
|
144
161
|
const fetchCollections = async () => {
|
|
145
162
|
const api = new PetSimulator99API();
|
|
@@ -157,7 +174,6 @@ const CollectionsIndex: React.FC = () => {
|
|
|
157
174
|
return () => window.removeEventListener("resize", handleResize);
|
|
158
175
|
}, []);
|
|
159
176
|
|
|
160
|
-
const isMobile = windowWidth < 768;
|
|
161
177
|
|
|
162
178
|
// Scroll Persistence
|
|
163
179
|
const { saveScrollPosition, getScrollPosition } = useScrollPersistence();
|
|
@@ -322,6 +338,33 @@ const CollectionsIndex: React.FC = () => {
|
|
|
322
338
|
</div>
|
|
323
339
|
)}
|
|
324
340
|
</div>
|
|
341
|
+
|
|
342
|
+
{/* Pull To Refresh Indicator */}
|
|
343
|
+
{(pullDistance > 0 || isRefreshing) && (
|
|
344
|
+
<div style={{
|
|
345
|
+
position: 'absolute',
|
|
346
|
+
top: showHeader ? headerHeight : 0,
|
|
347
|
+
left: 0,
|
|
348
|
+
right: 0,
|
|
349
|
+
height: isRefreshing ? 60 : pullDistance,
|
|
350
|
+
display: 'flex',
|
|
351
|
+
alignItems: 'center',
|
|
352
|
+
justifyContent: 'center',
|
|
353
|
+
overflow: 'hidden',
|
|
354
|
+
backgroundColor: '#f5f5f5',
|
|
355
|
+
zIndex: 5,
|
|
356
|
+
transition: isDragging ? 'none' : 'height 0.3s ease'
|
|
357
|
+
}}>
|
|
358
|
+
{isRefreshing ? (
|
|
359
|
+
<div className="spinner" style={{ width: 24, height: 24, border: '3px solid #ccc', borderTopColor: '#333', borderRadius: '50%' }}></div>
|
|
360
|
+
) : (
|
|
361
|
+
<span style={{ opacity: Math.min(pullDistance / 60, 1), transform: `rotate(${pullDistance * 2}deg)` }}>
|
|
362
|
+
⬇️
|
|
363
|
+
</span>
|
|
364
|
+
)}
|
|
365
|
+
</div>
|
|
366
|
+
)}
|
|
367
|
+
|
|
325
368
|
{/* Content */}
|
|
326
369
|
<div style={{ height: "100%", width: "100%", flex: 1, paddingTop: isMobile ? contentPadding : "0px", transition: "padding-top 0.3s ease-in-out" }}>
|
|
327
370
|
{/* @ts-ignore */}
|
|
@@ -336,7 +379,10 @@ const CollectionsIndex: React.FC = () => {
|
|
|
336
379
|
itemSize={80}
|
|
337
380
|
width={width}
|
|
338
381
|
initialScrollOffset={initialScrollOffset}
|
|
339
|
-
onScroll={
|
|
382
|
+
onScroll={onScroll}
|
|
383
|
+
onTouchStart={onTouchStart}
|
|
384
|
+
onTouchMove={onTouchMove}
|
|
385
|
+
onTouchEnd={onTouchEnd}
|
|
340
386
|
itemData={{
|
|
341
387
|
items: filteredCollections,
|
|
342
388
|
navigate
|
|
@@ -364,7 +410,10 @@ const CollectionsIndex: React.FC = () => {
|
|
|
364
410
|
rowHeight={rowHeight}
|
|
365
411
|
width={width}
|
|
366
412
|
initialScrollOffset={initialScrollOffset}
|
|
367
|
-
onScroll={
|
|
413
|
+
onScroll={onScroll}
|
|
414
|
+
onTouchStart={onTouchStart}
|
|
415
|
+
onTouchMove={onTouchMove}
|
|
416
|
+
onTouchEnd={onTouchEnd}
|
|
368
417
|
itemData={{
|
|
369
418
|
items: filteredCollections,
|
|
370
419
|
columnCount,
|
|
@@ -3,9 +3,10 @@ import { useState, useEffect, useRef } from 'react';
|
|
|
3
3
|
interface PullToRefreshOptions {
|
|
4
4
|
onRefresh: () => Promise<void> | void;
|
|
5
5
|
threshold?: number; // px to pull down to trigger
|
|
6
|
+
disabled?: boolean;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
|
-
export const usePullToRefresh = ({ onRefresh, threshold = 80 }: PullToRefreshOptions) => {
|
|
9
|
+
export const usePullToRefresh = ({ onRefresh, threshold = 80, disabled = false }: PullToRefreshOptions) => {
|
|
9
10
|
const [isRefreshing, setIsRefreshing] = useState(false);
|
|
10
11
|
const [pullDistance, setPullDistance] = useState(0);
|
|
11
12
|
const startY = useRef<number>(0);
|
|
@@ -15,6 +16,7 @@ export const usePullToRefresh = ({ onRefresh, threshold = 80 }: PullToRefreshOpt
|
|
|
15
16
|
const scrollTopRef = useRef(0);
|
|
16
17
|
|
|
17
18
|
const onTouchStart = (e: React.TouchEvent) => {
|
|
19
|
+
if (disabled) return;
|
|
18
20
|
if (scrollTopRef.current === 0) {
|
|
19
21
|
startY.current = e.touches[0].clientY;
|
|
20
22
|
isDragging.current = true;
|