@lani.ground/react-hooks
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -0,1 +1,2 @@ | ||
/// <reference types="react" /> | ||
interface Props { | ||
@@ -2,0 +3,0 @@ key?: string; |
@@ -15,3 +15,9 @@ "use strict"; | ||
}, []); | ||
var cancelScrollEvent = (0, react_1.useCallback)(function (event) { | ||
event.preventDefault(); | ||
}, []); | ||
var lockScroll = function () { | ||
var isScrollLocked = document.body.style.position === 'fixed'; | ||
if (isScrollLocked) | ||
return; | ||
scrollRef.current = window.scrollY; | ||
@@ -25,2 +31,5 @@ modifyBodyStyle({ | ||
}); | ||
document.addEventListener('touchmove', cancelScrollEvent, { | ||
passive: false, | ||
}); | ||
}; | ||
@@ -36,2 +45,5 @@ var unlockScroll = function () { | ||
window.scrollTo({ left: 0, top: scrollRef.current, behavior: 'instant' }); | ||
document.addEventListener('touchmove', cancelScrollEvent, { | ||
passive: false, | ||
}); | ||
}; | ||
@@ -38,0 +50,0 @@ return { |
@@ -0,1 +1,2 @@ | ||
/// <reference types="react" /> | ||
interface Props { | ||
@@ -2,0 +3,0 @@ key?: string; |
@@ -13,3 +13,9 @@ import { useCallback, useRef } from 'react'; | ||
}, []); | ||
var cancelScrollEvent = useCallback(function (event) { | ||
event.preventDefault(); | ||
}, []); | ||
var lockScroll = function () { | ||
var isScrollLocked = document.body.style.position === 'fixed'; | ||
if (isScrollLocked) | ||
return; | ||
scrollRef.current = window.scrollY; | ||
@@ -23,2 +29,5 @@ modifyBodyStyle({ | ||
}); | ||
document.addEventListener('touchmove', cancelScrollEvent, { | ||
passive: false, | ||
}); | ||
}; | ||
@@ -34,2 +43,5 @@ var unlockScroll = function () { | ||
window.scrollTo({ left: 0, top: scrollRef.current, behavior: 'instant' }); | ||
document.addEventListener('touchmove', cancelScrollEvent, { | ||
passive: false, | ||
}); | ||
}; | ||
@@ -36,0 +48,0 @@ return { |
{ | ||
"name": "@lani.ground/react-hooks", | ||
"description": "react hooks", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"keywords": [ | ||
@@ -73,3 +73,3 @@ "react-hooks", | ||
}, | ||
"gitHead": "4b223121d27a813a98864c47013e4b856b0b6e1a" | ||
"gitHead": "edbc9ab5d456073ba4154f0e04a35ae71311eda9" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22821
450