@citygross/components 0.8.23 → 0.8.24

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.
@@ -361,6 +361,28 @@ var useOutsideClick = function (ref, callback) {
361
361
  });
362
362
  };
363
363
 
364
+ var useFixedModalScroll = function (active, querySelector) {
365
+ var _a = React.useState(0), prevPosition = _a[0], setPrevPosition = _a[1];
366
+ React.useEffect(function () {
367
+ var pos = window === null || window === void 0 ? void 0 : window.scrollY;
368
+ var selector = querySelector || (document === null || document === void 0 ? void 0 : document.body);
369
+ if (active && selector) {
370
+ setPrevPosition(pos);
371
+ selector.style.overflowY = 'scroll';
372
+ selector.style.position = 'fixed';
373
+ selector.style.top = -pos + 'px';
374
+ }
375
+ else {
376
+ selector.style.removeProperty('top');
377
+ selector.style.overflowY = 'auto';
378
+ selector.style.position = 'relative';
379
+ if (prevPosition) {
380
+ window.scrollTo(0, prevPosition);
381
+ }
382
+ }
383
+ }, [active, querySelector]);
384
+ };
385
+
364
386
  function comparisonTypes(type) {
365
387
  switch (type) {
366
388
  case 'KGM':
@@ -18727,6 +18749,7 @@ build.moment = moment;
18727
18749
  build.nameRegex = nameRegex;
18728
18750
  build.phoneRegex = phoneRegex;
18729
18751
  build.useDetectDevice = useDetectDevice;
18752
+ build.useFixedModalScroll = useFixedModalScroll;
18730
18753
  build.useOutsideClick = useOutsideClick;
18731
18754
  var useWindowSize_1 = build.useWindowSize = useWindowSize;
18732
18755
  build.validateInput = validateInput;