@doyourjob/gravity-ui-page-constructor 5.31.239 → 5.31.241

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.
@@ -54,6 +54,7 @@ unpredictable css rules order in build */
54
54
  }
55
55
  .pc-scroller-block__content_scroll-snap-center {
56
56
  scroll-snap-type: x mandatory;
57
+ scroll-behavior: smooth;
57
58
  }
58
59
  .pc-scroller-block__content_scroll-snap-center .pc-scroller-block__item {
59
60
  scroll-snap-align: center;
@@ -39,6 +39,8 @@ const ScrollerBlock = (props) => {
39
39
  const contentRef = (0, react_1.useRef)(null);
40
40
  const [currentElement, setCurrentElement] = (0, react_1.useState)(0);
41
41
  const [isPaused, setIsPaused] = (0, react_1.useState)(true);
42
+ const [scrollInProgress, setScrollInProgress] = (0, react_1.useState)(false);
43
+ const scrollIntervalRef = (0, react_1.useRef)(null);
42
44
  (0, react_1.useEffect)(() => {
43
45
  const content = contentRef.current;
44
46
  const root = rootRef.current;
@@ -47,7 +49,7 @@ const ScrollerBlock = (props) => {
47
49
  return;
48
50
  }
49
51
  if (fullWidth) {
50
- const space = (window.innerWidth - root.clientWidth) / 2;
52
+ const space = (document.documentElement.clientWidth - root.clientWidth) / 2;
51
53
  content.style.setProperty('padding-left', `${space}px`);
52
54
  content.style.setProperty('padding-right', `${space}px`);
53
55
  content.style.setProperty('left', `${-space}px`);
@@ -100,6 +102,13 @@ const ScrollerBlock = (props) => {
100
102
  content.scrollTo(endChild.offsetLeft - content.clientWidth, 0);
101
103
  }
102
104
  }
105
+ setScrollInProgress(true);
106
+ if (scrollIntervalRef.current) {
107
+ clearTimeout(scrollIntervalRef.current);
108
+ }
109
+ scrollIntervalRef.current = setTimeout(() => {
110
+ setScrollInProgress(false);
111
+ }, 200);
103
112
  };
104
113
  content.addEventListener('scroll', handleInfiniteScroll, { passive: true });
105
114
  scrollToMiddle();
@@ -186,7 +195,7 @@ const ScrollerBlock = (props) => {
186
195
  react_1.default.createElement("div", { className: b('content', {
187
196
  gapLong,
188
197
  fullWidth,
189
- 'scroll-snap-center': infinite ? false : scrollSnapCenter,
198
+ 'scroll-snap-center': infinite ? !scrollInProgress : scrollSnapCenter,
190
199
  }), ref: contentRef }, (infinite ? [0, 1, 2] : [0])
191
200
  .map((mi) => react_1.default.Children.map(children, (child, index) => {
192
201
  const physicalIndex = mi * childCount + index;
@@ -54,6 +54,7 @@ unpredictable css rules order in build */
54
54
  }
55
55
  .pc-scroller-block__content_scroll-snap-center {
56
56
  scroll-snap-type: x mandatory;
57
+ scroll-behavior: smooth;
57
58
  }
58
59
  .pc-scroller-block__content_scroll-snap-center .pc-scroller-block__item {
59
60
  scroll-snap-align: center;
@@ -36,6 +36,8 @@ export const ScrollerBlock = (props) => {
36
36
  const contentRef = useRef(null);
37
37
  const [currentElement, setCurrentElement] = useState(0);
38
38
  const [isPaused, setIsPaused] = useState(true);
39
+ const [scrollInProgress, setScrollInProgress] = useState(false);
40
+ const scrollIntervalRef = useRef(null);
39
41
  useEffect(() => {
40
42
  const content = contentRef.current;
41
43
  const root = rootRef.current;
@@ -44,7 +46,7 @@ export const ScrollerBlock = (props) => {
44
46
  return;
45
47
  }
46
48
  if (fullWidth) {
47
- const space = (window.innerWidth - root.clientWidth) / 2;
49
+ const space = (document.documentElement.clientWidth - root.clientWidth) / 2;
48
50
  content.style.setProperty('padding-left', `${space}px`);
49
51
  content.style.setProperty('padding-right', `${space}px`);
50
52
  content.style.setProperty('left', `${-space}px`);
@@ -97,6 +99,13 @@ export const ScrollerBlock = (props) => {
97
99
  content.scrollTo(endChild.offsetLeft - content.clientWidth, 0);
98
100
  }
99
101
  }
102
+ setScrollInProgress(true);
103
+ if (scrollIntervalRef.current) {
104
+ clearTimeout(scrollIntervalRef.current);
105
+ }
106
+ scrollIntervalRef.current = setTimeout(() => {
107
+ setScrollInProgress(false);
108
+ }, 200);
100
109
  };
101
110
  content.addEventListener('scroll', handleInfiniteScroll, { passive: true });
102
111
  scrollToMiddle();
@@ -183,7 +192,7 @@ export const ScrollerBlock = (props) => {
183
192
  React.createElement("div", { className: b('content', {
184
193
  gapLong,
185
194
  fullWidth,
186
- 'scroll-snap-center': infinite ? false : scrollSnapCenter,
195
+ 'scroll-snap-center': infinite ? !scrollInProgress : scrollSnapCenter,
187
196
  }), ref: contentRef }, (infinite ? [0, 1, 2] : [0])
188
197
  .map((mi) => React.Children.map(children, (child, index) => {
189
198
  const physicalIndex = mi * childCount + index;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doyourjob/gravity-ui-page-constructor",
3
- "version": "5.31.239",
3
+ "version": "5.31.241",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {