catchup-library-web 1.21.4 → 1.21.6

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: "end"
5396
+ block: "center"
5397
5397
  });
5398
5398
  }
5399
5399
  }
@@ -5805,10 +5805,22 @@ var MatchingActivityMaterialContent = ({
5805
5805
  if (dropTargetKey && dropZoneRefs.current[dropTargetKey]) {
5806
5806
  const dropZoneElement = dropZoneRefs.current[dropTargetKey];
5807
5807
  if (dropZoneElement) {
5808
- dropZoneElement.scrollIntoView({
5809
- behavior: "smooth",
5810
- block: "end"
5811
- });
5808
+ const targetPosition = dropZoneElement.getBoundingClientRect().top + window.pageYOffset;
5809
+ const startPosition = window.pageYOffset;
5810
+ const distance = targetPosition - startPosition - window.innerHeight / 2 + dropZoneElement.offsetHeight / 2;
5811
+ const duration = 1e3;
5812
+ let start = null;
5813
+ const animation = (currentTime) => {
5814
+ if (start === null) start = currentTime;
5815
+ const timeElapsed = currentTime - start;
5816
+ const progress = Math.min(timeElapsed / duration, 1);
5817
+ const ease = (t) => t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
5818
+ window.scrollTo(0, startPosition + distance * ease(progress));
5819
+ if (timeElapsed < duration) {
5820
+ requestAnimationFrame(animation);
5821
+ }
5822
+ };
5823
+ requestAnimationFrame(animation);
5812
5824
  }
5813
5825
  }
5814
5826
  }, [dropTargetKey]);
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: "end"
5180
+ block: "center"
5181
5181
  });
5182
5182
  }
5183
5183
  }
@@ -5589,10 +5589,22 @@ var MatchingActivityMaterialContent = ({
5589
5589
  if (dropTargetKey && dropZoneRefs.current[dropTargetKey]) {
5590
5590
  const dropZoneElement = dropZoneRefs.current[dropTargetKey];
5591
5591
  if (dropZoneElement) {
5592
- dropZoneElement.scrollIntoView({
5593
- behavior: "smooth",
5594
- block: "end"
5595
- });
5592
+ const targetPosition = dropZoneElement.getBoundingClientRect().top + window.pageYOffset;
5593
+ const startPosition = window.pageYOffset;
5594
+ const distance = targetPosition - startPosition - window.innerHeight / 2 + dropZoneElement.offsetHeight / 2;
5595
+ const duration = 1e3;
5596
+ let start = null;
5597
+ const animation = (currentTime) => {
5598
+ if (start === null) start = currentTime;
5599
+ const timeElapsed = currentTime - start;
5600
+ const progress = Math.min(timeElapsed / duration, 1);
5601
+ const ease = (t) => t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
5602
+ window.scrollTo(0, startPosition + distance * ease(progress));
5603
+ if (timeElapsed < duration) {
5604
+ requestAnimationFrame(animation);
5605
+ }
5606
+ };
5607
+ requestAnimationFrame(animation);
5596
5608
  }
5597
5609
  }
5598
5610
  }, [dropTargetKey]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "catchup-library-web",
3
- "version": "1.21.04",
3
+ "version": "1.21.06",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -71,7 +71,7 @@ const GroupingActivityMaterialContent = ({
71
71
  if (dropZoneElement) {
72
72
  dropZoneElement.scrollIntoView({
73
73
  behavior: "smooth",
74
- block: "end",
74
+ block: "center",
75
75
  });
76
76
  }
77
77
  }
@@ -66,10 +66,34 @@ const MatchingActivityMaterialContent = ({
66
66
  if (dropTargetKey && dropZoneRefs.current[dropTargetKey]) {
67
67
  const dropZoneElement = dropZoneRefs.current[dropTargetKey];
68
68
  if (dropZoneElement) {
69
- dropZoneElement.scrollIntoView({
70
- behavior: "smooth",
71
- block: "end",
72
- });
69
+ const targetPosition =
70
+ dropZoneElement.getBoundingClientRect().top + window.pageYOffset;
71
+ const startPosition = window.pageYOffset;
72
+ const distance =
73
+ targetPosition -
74
+ startPosition -
75
+ window.innerHeight / 2 +
76
+ dropZoneElement.offsetHeight / 2;
77
+ const duration = 1000;
78
+ let start: number | null = null;
79
+
80
+ const animation = (currentTime: number) => {
81
+ if (start === null) start = currentTime;
82
+ const timeElapsed = currentTime - start;
83
+ const progress = Math.min(timeElapsed / duration, 1);
84
+
85
+ // Easing function for smooth animation
86
+ const ease = (t: number) =>
87
+ t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
88
+
89
+ window.scrollTo(0, startPosition + distance * ease(progress));
90
+
91
+ if (timeElapsed < duration) {
92
+ requestAnimationFrame(animation);
93
+ }
94
+ };
95
+
96
+ requestAnimationFrame(animation);
73
97
  }
74
98
  }
75
99
  }, [dropTargetKey]);