catchup-library-web 1.21.4 → 1.21.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/dist/index.js
CHANGED
|
@@ -5393,7 +5393,7 @@ var GroupingActivityMaterialContent = ({
|
|
|
5393
5393
|
if (dropZoneElement) {
|
|
5394
5394
|
dropZoneElement.scrollIntoView({
|
|
5395
5395
|
behavior: "smooth",
|
|
5396
|
-
block: "
|
|
5396
|
+
block: "center"
|
|
5397
5397
|
});
|
|
5398
5398
|
}
|
|
5399
5399
|
}
|
|
@@ -5776,6 +5776,7 @@ var MatchingActivityMaterialContent = ({
|
|
|
5776
5776
|
});
|
|
5777
5777
|
const itemsRef = (0, import_react21.useRef)(null);
|
|
5778
5778
|
const dropZoneRefs = (0, import_react21.useRef)({});
|
|
5779
|
+
const scrollIntervalRef = (0, import_react21.useRef)(null);
|
|
5779
5780
|
(0, import_react21.useEffect)(() => {
|
|
5780
5781
|
const shuffleArray2 = (array) => {
|
|
5781
5782
|
if (!isShuffled) {
|
|
@@ -5801,17 +5802,35 @@ var MatchingActivityMaterialContent = ({
|
|
|
5801
5802
|
(answerData) => answerData.type === "MATCHING"
|
|
5802
5803
|
).answerMap = materialMap;
|
|
5803
5804
|
}, [showCorrectAnswer, answer, materialMap]);
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5805
|
+
const handleAutoScroll = (clientY) => {
|
|
5806
|
+
const scrollThreshold = 100;
|
|
5807
|
+
const scrollSpeed = 10;
|
|
5808
|
+
const viewportHeight = window.innerHeight;
|
|
5809
|
+
if (scrollIntervalRef.current) {
|
|
5810
|
+
clearInterval(scrollIntervalRef.current);
|
|
5811
|
+
scrollIntervalRef.current = null;
|
|
5812
|
+
}
|
|
5813
|
+
if (clientY > viewportHeight - scrollThreshold) {
|
|
5814
|
+
scrollIntervalRef.current = setInterval(() => {
|
|
5815
|
+
window.scrollBy(0, scrollSpeed);
|
|
5816
|
+
}, 16);
|
|
5817
|
+
} else if (clientY < scrollThreshold) {
|
|
5818
|
+
scrollIntervalRef.current = setInterval(() => {
|
|
5819
|
+
window.scrollBy(0, -scrollSpeed);
|
|
5820
|
+
}, 16);
|
|
5813
5821
|
}
|
|
5814
|
-
}
|
|
5822
|
+
};
|
|
5823
|
+
const stopAutoScroll = () => {
|
|
5824
|
+
if (scrollIntervalRef.current) {
|
|
5825
|
+
clearInterval(scrollIntervalRef.current);
|
|
5826
|
+
scrollIntervalRef.current = null;
|
|
5827
|
+
}
|
|
5828
|
+
};
|
|
5829
|
+
(0, import_react21.useEffect)(() => {
|
|
5830
|
+
return () => {
|
|
5831
|
+
stopAutoScroll();
|
|
5832
|
+
};
|
|
5833
|
+
}, []);
|
|
5815
5834
|
const retrieveAnswerMap = () => {
|
|
5816
5835
|
const foundIndex = answer.data.findIndex(
|
|
5817
5836
|
(answerData) => answerData.type === "MATCHING"
|
|
@@ -5845,6 +5864,7 @@ var MatchingActivityMaterialContent = ({
|
|
|
5845
5864
|
const handleMouseMove = (e) => {
|
|
5846
5865
|
if (!draggedValue) return;
|
|
5847
5866
|
setMousePosition({ x: e.clientX, y: e.clientY });
|
|
5867
|
+
handleAutoScroll(e.clientY);
|
|
5848
5868
|
const elementUnder = document.elementFromPoint(e.clientX, e.clientY);
|
|
5849
5869
|
const dropZone = elementUnder == null ? void 0 : elementUnder.closest("[data-matching-drop-zone]");
|
|
5850
5870
|
if (dropZone) {
|
|
@@ -5855,6 +5875,7 @@ var MatchingActivityMaterialContent = ({
|
|
|
5855
5875
|
}
|
|
5856
5876
|
};
|
|
5857
5877
|
const handleMouseUp = () => {
|
|
5878
|
+
stopAutoScroll();
|
|
5858
5879
|
if (dropTargetKey !== null && draggedValue !== null) {
|
|
5859
5880
|
onChange(answer, dropTargetKey, draggedValue);
|
|
5860
5881
|
}
|
|
@@ -5874,6 +5895,7 @@ var MatchingActivityMaterialContent = ({
|
|
|
5874
5895
|
if (!draggedValue) return;
|
|
5875
5896
|
const touch = e.touches[0];
|
|
5876
5897
|
setTouchPosition({ x: touch.clientX, y: touch.clientY });
|
|
5898
|
+
handleAutoScroll(touch.clientY);
|
|
5877
5899
|
const elementUnder = document.elementFromPoint(
|
|
5878
5900
|
touch.clientX,
|
|
5879
5901
|
touch.clientY
|
|
@@ -5887,6 +5909,7 @@ var MatchingActivityMaterialContent = ({
|
|
|
5887
5909
|
}
|
|
5888
5910
|
};
|
|
5889
5911
|
const handleTouchEnd = () => {
|
|
5912
|
+
stopAutoScroll();
|
|
5890
5913
|
if (dropTargetKey !== null && draggedValue !== null) {
|
|
5891
5914
|
onChange(answer, dropTargetKey, draggedValue);
|
|
5892
5915
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -5177,7 +5177,7 @@ var GroupingActivityMaterialContent = ({
|
|
|
5177
5177
|
if (dropZoneElement) {
|
|
5178
5178
|
dropZoneElement.scrollIntoView({
|
|
5179
5179
|
behavior: "smooth",
|
|
5180
|
-
block: "
|
|
5180
|
+
block: "center"
|
|
5181
5181
|
});
|
|
5182
5182
|
}
|
|
5183
5183
|
}
|
|
@@ -5560,6 +5560,7 @@ var MatchingActivityMaterialContent = ({
|
|
|
5560
5560
|
});
|
|
5561
5561
|
const itemsRef = useRef6(null);
|
|
5562
5562
|
const dropZoneRefs = useRef6({});
|
|
5563
|
+
const scrollIntervalRef = useRef6(null);
|
|
5563
5564
|
useEffect11(() => {
|
|
5564
5565
|
const shuffleArray2 = (array) => {
|
|
5565
5566
|
if (!isShuffled) {
|
|
@@ -5585,17 +5586,35 @@ var MatchingActivityMaterialContent = ({
|
|
|
5585
5586
|
(answerData) => answerData.type === "MATCHING"
|
|
5586
5587
|
).answerMap = materialMap;
|
|
5587
5588
|
}, [showCorrectAnswer, answer, materialMap]);
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5589
|
+
const handleAutoScroll = (clientY) => {
|
|
5590
|
+
const scrollThreshold = 100;
|
|
5591
|
+
const scrollSpeed = 10;
|
|
5592
|
+
const viewportHeight = window.innerHeight;
|
|
5593
|
+
if (scrollIntervalRef.current) {
|
|
5594
|
+
clearInterval(scrollIntervalRef.current);
|
|
5595
|
+
scrollIntervalRef.current = null;
|
|
5596
|
+
}
|
|
5597
|
+
if (clientY > viewportHeight - scrollThreshold) {
|
|
5598
|
+
scrollIntervalRef.current = setInterval(() => {
|
|
5599
|
+
window.scrollBy(0, scrollSpeed);
|
|
5600
|
+
}, 16);
|
|
5601
|
+
} else if (clientY < scrollThreshold) {
|
|
5602
|
+
scrollIntervalRef.current = setInterval(() => {
|
|
5603
|
+
window.scrollBy(0, -scrollSpeed);
|
|
5604
|
+
}, 16);
|
|
5597
5605
|
}
|
|
5598
|
-
}
|
|
5606
|
+
};
|
|
5607
|
+
const stopAutoScroll = () => {
|
|
5608
|
+
if (scrollIntervalRef.current) {
|
|
5609
|
+
clearInterval(scrollIntervalRef.current);
|
|
5610
|
+
scrollIntervalRef.current = null;
|
|
5611
|
+
}
|
|
5612
|
+
};
|
|
5613
|
+
useEffect11(() => {
|
|
5614
|
+
return () => {
|
|
5615
|
+
stopAutoScroll();
|
|
5616
|
+
};
|
|
5617
|
+
}, []);
|
|
5599
5618
|
const retrieveAnswerMap = () => {
|
|
5600
5619
|
const foundIndex = answer.data.findIndex(
|
|
5601
5620
|
(answerData) => answerData.type === "MATCHING"
|
|
@@ -5629,6 +5648,7 @@ var MatchingActivityMaterialContent = ({
|
|
|
5629
5648
|
const handleMouseMove = (e) => {
|
|
5630
5649
|
if (!draggedValue) return;
|
|
5631
5650
|
setMousePosition({ x: e.clientX, y: e.clientY });
|
|
5651
|
+
handleAutoScroll(e.clientY);
|
|
5632
5652
|
const elementUnder = document.elementFromPoint(e.clientX, e.clientY);
|
|
5633
5653
|
const dropZone = elementUnder == null ? void 0 : elementUnder.closest("[data-matching-drop-zone]");
|
|
5634
5654
|
if (dropZone) {
|
|
@@ -5639,6 +5659,7 @@ var MatchingActivityMaterialContent = ({
|
|
|
5639
5659
|
}
|
|
5640
5660
|
};
|
|
5641
5661
|
const handleMouseUp = () => {
|
|
5662
|
+
stopAutoScroll();
|
|
5642
5663
|
if (dropTargetKey !== null && draggedValue !== null) {
|
|
5643
5664
|
onChange(answer, dropTargetKey, draggedValue);
|
|
5644
5665
|
}
|
|
@@ -5658,6 +5679,7 @@ var MatchingActivityMaterialContent = ({
|
|
|
5658
5679
|
if (!draggedValue) return;
|
|
5659
5680
|
const touch = e.touches[0];
|
|
5660
5681
|
setTouchPosition({ x: touch.clientX, y: touch.clientY });
|
|
5682
|
+
handleAutoScroll(touch.clientY);
|
|
5661
5683
|
const elementUnder = document.elementFromPoint(
|
|
5662
5684
|
touch.clientX,
|
|
5663
5685
|
touch.clientY
|
|
@@ -5671,6 +5693,7 @@ var MatchingActivityMaterialContent = ({
|
|
|
5671
5693
|
}
|
|
5672
5694
|
};
|
|
5673
5695
|
const handleTouchEnd = () => {
|
|
5696
|
+
stopAutoScroll();
|
|
5674
5697
|
if (dropTargetKey !== null && draggedValue !== null) {
|
|
5675
5698
|
onChange(answer, dropTargetKey, draggedValue);
|
|
5676
5699
|
}
|
package/package.json
CHANGED
|
@@ -34,6 +34,7 @@ const MatchingActivityMaterialContent = ({
|
|
|
34
34
|
});
|
|
35
35
|
const itemsRef = useRef<HTMLDivElement>(null);
|
|
36
36
|
const dropZoneRefs = useRef<{ [key: string]: HTMLDivElement | null }>({});
|
|
37
|
+
const scrollIntervalRef = useRef<number | null>(null);
|
|
37
38
|
|
|
38
39
|
useEffect(() => {
|
|
39
40
|
const shuffleArray = (array: any) => {
|
|
@@ -62,17 +63,45 @@ const MatchingActivityMaterialContent = ({
|
|
|
62
63
|
).answerMap = materialMap;
|
|
63
64
|
}, [showCorrectAnswer, answer, materialMap]);
|
|
64
65
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
// Auto-scroll function
|
|
67
|
+
const handleAutoScroll = (clientY: number) => {
|
|
68
|
+
const scrollThreshold = 100; // Distance from edge to trigger scroll
|
|
69
|
+
const scrollSpeed = 10; // Pixels to scroll per interval
|
|
70
|
+
const viewportHeight = window.innerHeight;
|
|
71
|
+
|
|
72
|
+
// Clear existing interval
|
|
73
|
+
if (scrollIntervalRef.current) {
|
|
74
|
+
clearInterval(scrollIntervalRef.current);
|
|
75
|
+
scrollIntervalRef.current = null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Scroll down when near bottom
|
|
79
|
+
if (clientY > viewportHeight - scrollThreshold) {
|
|
80
|
+
scrollIntervalRef.current = setInterval(() => {
|
|
81
|
+
window.scrollBy(0, scrollSpeed);
|
|
82
|
+
}, 16); // ~60fps
|
|
83
|
+
}
|
|
84
|
+
// Scroll up when near top
|
|
85
|
+
else if (clientY < scrollThreshold) {
|
|
86
|
+
scrollIntervalRef.current = setInterval(() => {
|
|
87
|
+
window.scrollBy(0, -scrollSpeed);
|
|
88
|
+
}, 16);
|
|
74
89
|
}
|
|
75
|
-
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const stopAutoScroll = () => {
|
|
93
|
+
if (scrollIntervalRef.current) {
|
|
94
|
+
clearInterval(scrollIntervalRef.current);
|
|
95
|
+
scrollIntervalRef.current = null;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// Cleanup on unmount
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
return () => {
|
|
102
|
+
stopAutoScroll();
|
|
103
|
+
};
|
|
104
|
+
}, []);
|
|
76
105
|
|
|
77
106
|
const retrieveAnswerMap = () => {
|
|
78
107
|
const foundIndex = answer.data.findIndex(
|
|
@@ -120,6 +149,9 @@ const MatchingActivityMaterialContent = ({
|
|
|
120
149
|
|
|
121
150
|
setMousePosition({ x: e.clientX, y: e.clientY });
|
|
122
151
|
|
|
152
|
+
// Handle auto-scroll
|
|
153
|
+
handleAutoScroll(e.clientY);
|
|
154
|
+
|
|
123
155
|
// Find the element under the mouse point
|
|
124
156
|
const elementUnder = document.elementFromPoint(e.clientX, e.clientY);
|
|
125
157
|
const dropZone = elementUnder?.closest("[data-matching-drop-zone]");
|
|
@@ -133,6 +165,7 @@ const MatchingActivityMaterialContent = ({
|
|
|
133
165
|
};
|
|
134
166
|
|
|
135
167
|
const handleMouseUp = (): void => {
|
|
168
|
+
stopAutoScroll();
|
|
136
169
|
if (dropTargetKey !== null && draggedValue !== null) {
|
|
137
170
|
onChange(answer, dropTargetKey, draggedValue);
|
|
138
171
|
}
|
|
@@ -161,6 +194,9 @@ const MatchingActivityMaterialContent = ({
|
|
|
161
194
|
const touch = e.touches[0];
|
|
162
195
|
setTouchPosition({ x: touch.clientX, y: touch.clientY });
|
|
163
196
|
|
|
197
|
+
// Handle auto-scroll
|
|
198
|
+
handleAutoScroll(touch.clientY);
|
|
199
|
+
|
|
164
200
|
// Find the element under the touch point
|
|
165
201
|
const elementUnder = document.elementFromPoint(
|
|
166
202
|
touch.clientX,
|
|
@@ -177,6 +213,7 @@ const MatchingActivityMaterialContent = ({
|
|
|
177
213
|
};
|
|
178
214
|
|
|
179
215
|
const handleTouchEnd = (): void => {
|
|
216
|
+
stopAutoScroll();
|
|
180
217
|
if (dropTargetKey !== null && draggedValue !== null) {
|
|
181
218
|
onChange(answer, dropTargetKey, draggedValue);
|
|
182
219
|
}
|