catchup-library-web 1.21.12 → 1.21.15
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
|
@@ -5388,32 +5388,48 @@ var GroupingActivityMaterialContent = ({
|
|
|
5388
5388
|
).answerMap = materialMap;
|
|
5389
5389
|
}, [showCorrectAnswer, answer, materialMap]);
|
|
5390
5390
|
(0, import_react20.useEffect)(() => {
|
|
5391
|
-
if (dropTargetKey
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
const
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
const animation = (currentTime) => {
|
|
5403
|
-
if (start === null) start = currentTime;
|
|
5404
|
-
const timeElapsed = currentTime - start;
|
|
5405
|
-
const progress = Math.min(timeElapsed / duration, 1);
|
|
5406
|
-
window.scrollTo(
|
|
5407
|
-
0,
|
|
5408
|
-
startPosition + distance * easeInOutQuad(progress)
|
|
5409
|
-
);
|
|
5410
|
-
if (timeElapsed < duration) {
|
|
5411
|
-
requestAnimationFrame(animation);
|
|
5412
|
-
}
|
|
5413
|
-
};
|
|
5414
|
-
requestAnimationFrame(animation);
|
|
5391
|
+
if (!dropTargetKey || !dropZoneRefs.current[dropTargetKey]) return;
|
|
5392
|
+
const dropZoneElement = dropZoneRefs.current[dropTargetKey];
|
|
5393
|
+
if (!dropZoneElement) return;
|
|
5394
|
+
const findScrollableParent = (element) => {
|
|
5395
|
+
let parent = element.parentElement;
|
|
5396
|
+
while (parent) {
|
|
5397
|
+
const { overflow, overflowY } = window.getComputedStyle(parent);
|
|
5398
|
+
if (overflow === "auto" || overflow === "scroll" || overflowY === "auto" || overflowY === "scroll") {
|
|
5399
|
+
return parent;
|
|
5400
|
+
}
|
|
5401
|
+
parent = parent.parentElement;
|
|
5415
5402
|
}
|
|
5416
|
-
|
|
5403
|
+
return document.documentElement;
|
|
5404
|
+
};
|
|
5405
|
+
const scrollContainer = findScrollableParent(dropZoneElement);
|
|
5406
|
+
if (!scrollContainer) return;
|
|
5407
|
+
const containerRect = scrollContainer.getBoundingClientRect();
|
|
5408
|
+
const elementRect = dropZoneElement.getBoundingClientRect();
|
|
5409
|
+
const elementTop = elementRect.top - containerRect.top + scrollContainer.scrollTop;
|
|
5410
|
+
const elementHeight = elementRect.height;
|
|
5411
|
+
const containerHeight = containerRect.height;
|
|
5412
|
+
const targetScroll = elementTop - containerHeight / 2 + elementHeight / 2;
|
|
5413
|
+
const startScroll = scrollContainer.scrollTop;
|
|
5414
|
+
const distance = targetScroll - startScroll;
|
|
5415
|
+
if (Math.abs(distance) < 10) return;
|
|
5416
|
+
const duration = 800;
|
|
5417
|
+
let startTime = null;
|
|
5418
|
+
const easeInOutQuad = (t) => {
|
|
5419
|
+
return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
|
5420
|
+
};
|
|
5421
|
+
const animate = (currentTime) => {
|
|
5422
|
+
if (startTime === null) startTime = currentTime;
|
|
5423
|
+
const elapsed = currentTime - startTime;
|
|
5424
|
+
const progress = Math.min(elapsed / duration, 1);
|
|
5425
|
+
const easedProgress = easeInOutQuad(progress);
|
|
5426
|
+
const newScrollTop = startScroll + distance * easedProgress;
|
|
5427
|
+
scrollContainer.scrollTop = newScrollTop;
|
|
5428
|
+
if (progress < 1) {
|
|
5429
|
+
requestAnimationFrame(animate);
|
|
5430
|
+
}
|
|
5431
|
+
};
|
|
5432
|
+
requestAnimationFrame(animate);
|
|
5417
5433
|
}, [dropTargetKey]);
|
|
5418
5434
|
const retrieveAnswerMap = () => {
|
|
5419
5435
|
const foundIndex = answer.data.findIndex(
|
|
@@ -5822,17 +5838,27 @@ var MatchingActivityMaterialContent = ({
|
|
|
5822
5838
|
if (!dropTargetKey || !dropZoneRefs.current[dropTargetKey]) return;
|
|
5823
5839
|
const dropZoneElement = dropZoneRefs.current[dropTargetKey];
|
|
5824
5840
|
if (!dropZoneElement) return;
|
|
5825
|
-
const
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5841
|
+
const findScrollableParent = (element) => {
|
|
5842
|
+
let parent = element.parentElement;
|
|
5843
|
+
while (parent) {
|
|
5844
|
+
const { overflow, overflowY } = window.getComputedStyle(parent);
|
|
5845
|
+
if (overflow === "auto" || overflow === "scroll" || overflowY === "auto" || overflowY === "scroll") {
|
|
5846
|
+
return parent;
|
|
5847
|
+
}
|
|
5848
|
+
parent = parent.parentElement;
|
|
5849
|
+
}
|
|
5850
|
+
return document.documentElement;
|
|
5851
|
+
};
|
|
5852
|
+
const scrollContainer = findScrollableParent(dropZoneElement);
|
|
5853
|
+
if (!scrollContainer) return;
|
|
5854
|
+
const containerRect = scrollContainer.getBoundingClientRect();
|
|
5855
|
+
const elementRect = dropZoneElement.getBoundingClientRect();
|
|
5856
|
+
const elementTop = elementRect.top - containerRect.top + scrollContainer.scrollTop;
|
|
5857
|
+
const elementHeight = elementRect.height;
|
|
5858
|
+
const containerHeight = containerRect.height;
|
|
5859
|
+
const targetScroll = elementTop - containerHeight / 2 + elementHeight / 2;
|
|
5860
|
+
const startScroll = scrollContainer.scrollTop;
|
|
5831
5861
|
const distance = targetScroll - startScroll;
|
|
5832
|
-
console.log("Scrolling to element:", dropTargetKey);
|
|
5833
|
-
console.log("Current scroll:", startScroll);
|
|
5834
|
-
console.log("Target scroll:", targetScroll);
|
|
5835
|
-
console.log("Distance:", distance);
|
|
5836
5862
|
if (Math.abs(distance) < 10) return;
|
|
5837
5863
|
const duration = 800;
|
|
5838
5864
|
let startTime = null;
|
|
@@ -5841,14 +5867,11 @@ var MatchingActivityMaterialContent = ({
|
|
|
5841
5867
|
};
|
|
5842
5868
|
const animate = (currentTime) => {
|
|
5843
5869
|
if (startTime === null) startTime = currentTime;
|
|
5844
|
-
console.log("startTime:", startTime);
|
|
5845
5870
|
const elapsed = currentTime - startTime;
|
|
5846
|
-
console.log("elapsed:", elapsed);
|
|
5847
5871
|
const progress = Math.min(elapsed / duration, 1);
|
|
5848
|
-
console.log("progress:", progress);
|
|
5849
5872
|
const easedProgress = easeInOutQuad(progress);
|
|
5850
|
-
|
|
5851
|
-
|
|
5873
|
+
const newScrollTop = startScroll + distance * easedProgress;
|
|
5874
|
+
scrollContainer.scrollTop = newScrollTop;
|
|
5852
5875
|
if (progress < 1) {
|
|
5853
5876
|
requestAnimationFrame(animate);
|
|
5854
5877
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -5172,32 +5172,48 @@ var GroupingActivityMaterialContent = ({
|
|
|
5172
5172
|
).answerMap = materialMap;
|
|
5173
5173
|
}, [showCorrectAnswer, answer, materialMap]);
|
|
5174
5174
|
useEffect10(() => {
|
|
5175
|
-
if (dropTargetKey
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
const
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
const animation = (currentTime) => {
|
|
5187
|
-
if (start === null) start = currentTime;
|
|
5188
|
-
const timeElapsed = currentTime - start;
|
|
5189
|
-
const progress = Math.min(timeElapsed / duration, 1);
|
|
5190
|
-
window.scrollTo(
|
|
5191
|
-
0,
|
|
5192
|
-
startPosition + distance * easeInOutQuad(progress)
|
|
5193
|
-
);
|
|
5194
|
-
if (timeElapsed < duration) {
|
|
5195
|
-
requestAnimationFrame(animation);
|
|
5196
|
-
}
|
|
5197
|
-
};
|
|
5198
|
-
requestAnimationFrame(animation);
|
|
5175
|
+
if (!dropTargetKey || !dropZoneRefs.current[dropTargetKey]) return;
|
|
5176
|
+
const dropZoneElement = dropZoneRefs.current[dropTargetKey];
|
|
5177
|
+
if (!dropZoneElement) return;
|
|
5178
|
+
const findScrollableParent = (element) => {
|
|
5179
|
+
let parent = element.parentElement;
|
|
5180
|
+
while (parent) {
|
|
5181
|
+
const { overflow, overflowY } = window.getComputedStyle(parent);
|
|
5182
|
+
if (overflow === "auto" || overflow === "scroll" || overflowY === "auto" || overflowY === "scroll") {
|
|
5183
|
+
return parent;
|
|
5184
|
+
}
|
|
5185
|
+
parent = parent.parentElement;
|
|
5199
5186
|
}
|
|
5200
|
-
|
|
5187
|
+
return document.documentElement;
|
|
5188
|
+
};
|
|
5189
|
+
const scrollContainer = findScrollableParent(dropZoneElement);
|
|
5190
|
+
if (!scrollContainer) return;
|
|
5191
|
+
const containerRect = scrollContainer.getBoundingClientRect();
|
|
5192
|
+
const elementRect = dropZoneElement.getBoundingClientRect();
|
|
5193
|
+
const elementTop = elementRect.top - containerRect.top + scrollContainer.scrollTop;
|
|
5194
|
+
const elementHeight = elementRect.height;
|
|
5195
|
+
const containerHeight = containerRect.height;
|
|
5196
|
+
const targetScroll = elementTop - containerHeight / 2 + elementHeight / 2;
|
|
5197
|
+
const startScroll = scrollContainer.scrollTop;
|
|
5198
|
+
const distance = targetScroll - startScroll;
|
|
5199
|
+
if (Math.abs(distance) < 10) return;
|
|
5200
|
+
const duration = 800;
|
|
5201
|
+
let startTime = null;
|
|
5202
|
+
const easeInOutQuad = (t) => {
|
|
5203
|
+
return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
|
5204
|
+
};
|
|
5205
|
+
const animate = (currentTime) => {
|
|
5206
|
+
if (startTime === null) startTime = currentTime;
|
|
5207
|
+
const elapsed = currentTime - startTime;
|
|
5208
|
+
const progress = Math.min(elapsed / duration, 1);
|
|
5209
|
+
const easedProgress = easeInOutQuad(progress);
|
|
5210
|
+
const newScrollTop = startScroll + distance * easedProgress;
|
|
5211
|
+
scrollContainer.scrollTop = newScrollTop;
|
|
5212
|
+
if (progress < 1) {
|
|
5213
|
+
requestAnimationFrame(animate);
|
|
5214
|
+
}
|
|
5215
|
+
};
|
|
5216
|
+
requestAnimationFrame(animate);
|
|
5201
5217
|
}, [dropTargetKey]);
|
|
5202
5218
|
const retrieveAnswerMap = () => {
|
|
5203
5219
|
const foundIndex = answer.data.findIndex(
|
|
@@ -5606,17 +5622,27 @@ var MatchingActivityMaterialContent = ({
|
|
|
5606
5622
|
if (!dropTargetKey || !dropZoneRefs.current[dropTargetKey]) return;
|
|
5607
5623
|
const dropZoneElement = dropZoneRefs.current[dropTargetKey];
|
|
5608
5624
|
if (!dropZoneElement) return;
|
|
5609
|
-
const
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5625
|
+
const findScrollableParent = (element) => {
|
|
5626
|
+
let parent = element.parentElement;
|
|
5627
|
+
while (parent) {
|
|
5628
|
+
const { overflow, overflowY } = window.getComputedStyle(parent);
|
|
5629
|
+
if (overflow === "auto" || overflow === "scroll" || overflowY === "auto" || overflowY === "scroll") {
|
|
5630
|
+
return parent;
|
|
5631
|
+
}
|
|
5632
|
+
parent = parent.parentElement;
|
|
5633
|
+
}
|
|
5634
|
+
return document.documentElement;
|
|
5635
|
+
};
|
|
5636
|
+
const scrollContainer = findScrollableParent(dropZoneElement);
|
|
5637
|
+
if (!scrollContainer) return;
|
|
5638
|
+
const containerRect = scrollContainer.getBoundingClientRect();
|
|
5639
|
+
const elementRect = dropZoneElement.getBoundingClientRect();
|
|
5640
|
+
const elementTop = elementRect.top - containerRect.top + scrollContainer.scrollTop;
|
|
5641
|
+
const elementHeight = elementRect.height;
|
|
5642
|
+
const containerHeight = containerRect.height;
|
|
5643
|
+
const targetScroll = elementTop - containerHeight / 2 + elementHeight / 2;
|
|
5644
|
+
const startScroll = scrollContainer.scrollTop;
|
|
5615
5645
|
const distance = targetScroll - startScroll;
|
|
5616
|
-
console.log("Scrolling to element:", dropTargetKey);
|
|
5617
|
-
console.log("Current scroll:", startScroll);
|
|
5618
|
-
console.log("Target scroll:", targetScroll);
|
|
5619
|
-
console.log("Distance:", distance);
|
|
5620
5646
|
if (Math.abs(distance) < 10) return;
|
|
5621
5647
|
const duration = 800;
|
|
5622
5648
|
let startTime = null;
|
|
@@ -5625,14 +5651,11 @@ var MatchingActivityMaterialContent = ({
|
|
|
5625
5651
|
};
|
|
5626
5652
|
const animate = (currentTime) => {
|
|
5627
5653
|
if (startTime === null) startTime = currentTime;
|
|
5628
|
-
console.log("startTime:", startTime);
|
|
5629
5654
|
const elapsed = currentTime - startTime;
|
|
5630
|
-
console.log("elapsed:", elapsed);
|
|
5631
5655
|
const progress = Math.min(elapsed / duration, 1);
|
|
5632
|
-
console.log("progress:", progress);
|
|
5633
5656
|
const easedProgress = easeInOutQuad(progress);
|
|
5634
|
-
|
|
5635
|
-
|
|
5657
|
+
const newScrollTop = startScroll + distance * easedProgress;
|
|
5658
|
+
scrollContainer.scrollTop = newScrollTop;
|
|
5636
5659
|
if (progress < 1) {
|
|
5637
5660
|
requestAnimationFrame(animate);
|
|
5638
5661
|
}
|
package/package.json
CHANGED
|
@@ -65,42 +65,69 @@ const GroupingActivityMaterialContent = ({
|
|
|
65
65
|
}, [showCorrectAnswer, answer, materialMap]);
|
|
66
66
|
|
|
67
67
|
useEffect(() => {
|
|
68
|
-
if (dropTargetKey
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const timeElapsed = currentTime - start;
|
|
89
|
-
const progress = Math.min(timeElapsed / duration, 1);
|
|
90
|
-
|
|
91
|
-
window.scrollTo(
|
|
92
|
-
0,
|
|
93
|
-
startPosition + distance * easeInOutQuad(progress)
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
if (timeElapsed < duration) {
|
|
97
|
-
requestAnimationFrame(animation);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
requestAnimationFrame(animation);
|
|
68
|
+
if (!dropTargetKey || !dropZoneRefs.current[dropTargetKey]) return;
|
|
69
|
+
|
|
70
|
+
const dropZoneElement = dropZoneRefs.current[dropTargetKey];
|
|
71
|
+
if (!dropZoneElement) return;
|
|
72
|
+
|
|
73
|
+
// Find the scrollable parent container
|
|
74
|
+
const findScrollableParent = (element: HTMLElement): HTMLElement | null => {
|
|
75
|
+
let parent = element.parentElement;
|
|
76
|
+
|
|
77
|
+
while (parent) {
|
|
78
|
+
const { overflow, overflowY } = window.getComputedStyle(parent);
|
|
79
|
+
if (
|
|
80
|
+
overflow === "auto" ||
|
|
81
|
+
overflow === "scroll" ||
|
|
82
|
+
overflowY === "auto" ||
|
|
83
|
+
overflowY === "scroll"
|
|
84
|
+
) {
|
|
85
|
+
return parent;
|
|
86
|
+
}
|
|
87
|
+
parent = parent.parentElement;
|
|
102
88
|
}
|
|
103
|
-
|
|
89
|
+
|
|
90
|
+
return document.documentElement;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const scrollContainer = findScrollableParent(dropZoneElement);
|
|
94
|
+
if (!scrollContainer) return;
|
|
95
|
+
|
|
96
|
+
const containerRect = scrollContainer.getBoundingClientRect();
|
|
97
|
+
const elementRect = dropZoneElement.getBoundingClientRect();
|
|
98
|
+
|
|
99
|
+
const elementTop =
|
|
100
|
+
elementRect.top - containerRect.top + scrollContainer.scrollTop;
|
|
101
|
+
const elementHeight = elementRect.height;
|
|
102
|
+
const containerHeight = containerRect.height;
|
|
103
|
+
|
|
104
|
+
const targetScroll = elementTop - containerHeight / 2 + elementHeight / 2;
|
|
105
|
+
const startScroll = scrollContainer.scrollTop;
|
|
106
|
+
const distance = targetScroll - startScroll;
|
|
107
|
+
if (Math.abs(distance) < 10) return;
|
|
108
|
+
|
|
109
|
+
const duration = 800;
|
|
110
|
+
let startTime: number | null = null;
|
|
111
|
+
|
|
112
|
+
const easeInOutQuad = (t: number): number => {
|
|
113
|
+
return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const animate = (currentTime: number) => {
|
|
117
|
+
if (startTime === null) startTime = currentTime;
|
|
118
|
+
|
|
119
|
+
const elapsed = currentTime - startTime;
|
|
120
|
+
const progress = Math.min(elapsed / duration, 1);
|
|
121
|
+
const easedProgress = easeInOutQuad(progress);
|
|
122
|
+
|
|
123
|
+
const newScrollTop = startScroll + distance * easedProgress;
|
|
124
|
+
scrollContainer.scrollTop = newScrollTop;
|
|
125
|
+
if (progress < 1) {
|
|
126
|
+
requestAnimationFrame(animate);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
requestAnimationFrame(animate);
|
|
104
131
|
}, [dropTargetKey]);
|
|
105
132
|
|
|
106
133
|
const retrieveAnswerMap = () => {
|
|
@@ -68,23 +68,40 @@ const MatchingActivityMaterialContent = ({
|
|
|
68
68
|
const dropZoneElement = dropZoneRefs.current[dropTargetKey];
|
|
69
69
|
if (!dropZoneElement) return;
|
|
70
70
|
|
|
71
|
-
//
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
71
|
+
// Find the scrollable parent container
|
|
72
|
+
const findScrollableParent = (element: HTMLElement): HTMLElement | null => {
|
|
73
|
+
let parent = element.parentElement;
|
|
74
|
+
|
|
75
|
+
while (parent) {
|
|
76
|
+
const { overflow, overflowY } = window.getComputedStyle(parent);
|
|
77
|
+
if (
|
|
78
|
+
overflow === "auto" ||
|
|
79
|
+
overflow === "scroll" ||
|
|
80
|
+
overflowY === "auto" ||
|
|
81
|
+
overflowY === "scroll"
|
|
82
|
+
) {
|
|
83
|
+
return parent;
|
|
84
|
+
}
|
|
85
|
+
parent = parent.parentElement;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return document.documentElement;
|
|
89
|
+
};
|
|
81
90
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
console.log("Target scroll:", targetScroll);
|
|
85
|
-
console.log("Distance:", distance);
|
|
91
|
+
const scrollContainer = findScrollableParent(dropZoneElement);
|
|
92
|
+
if (!scrollContainer) return;
|
|
86
93
|
|
|
87
|
-
|
|
94
|
+
const containerRect = scrollContainer.getBoundingClientRect();
|
|
95
|
+
const elementRect = dropZoneElement.getBoundingClientRect();
|
|
96
|
+
|
|
97
|
+
const elementTop =
|
|
98
|
+
elementRect.top - containerRect.top + scrollContainer.scrollTop;
|
|
99
|
+
const elementHeight = elementRect.height;
|
|
100
|
+
const containerHeight = containerRect.height;
|
|
101
|
+
|
|
102
|
+
const targetScroll = elementTop - containerHeight / 2 + elementHeight / 2;
|
|
103
|
+
const startScroll = scrollContainer.scrollTop;
|
|
104
|
+
const distance = targetScroll - startScroll;
|
|
88
105
|
if (Math.abs(distance) < 10) return;
|
|
89
106
|
|
|
90
107
|
const duration = 800;
|
|
@@ -97,16 +114,12 @@ const MatchingActivityMaterialContent = ({
|
|
|
97
114
|
const animate = (currentTime: number) => {
|
|
98
115
|
if (startTime === null) startTime = currentTime;
|
|
99
116
|
|
|
100
|
-
console.log("startTime:", startTime);
|
|
101
117
|
const elapsed = currentTime - startTime;
|
|
102
|
-
console.log("elapsed:", elapsed);
|
|
103
118
|
const progress = Math.min(elapsed / duration, 1);
|
|
104
|
-
console.log("progress:", progress);
|
|
105
119
|
const easedProgress = easeInOutQuad(progress);
|
|
106
|
-
console.log("eased progressed: ", easedProgress);
|
|
107
|
-
|
|
108
|
-
window.scrollTo(0, startScroll + distance * easedProgress);
|
|
109
120
|
|
|
121
|
+
const newScrollTop = startScroll + distance * easedProgress;
|
|
122
|
+
scrollContainer.scrollTop = newScrollTop;
|
|
110
123
|
if (progress < 1) {
|
|
111
124
|
requestAnimationFrame(animate);
|
|
112
125
|
}
|