File tree Expand file tree Collapse file tree 2 files changed +31
-6
lines changed Expand file tree Collapse file tree 2 files changed +31
-6
lines changed Original file line number Diff line number Diff line change 22 "name" : " react-ios-scroll-lock" ,
33 "author" : " Arsen Mkrtchyan (stripearmy)" ,
44 "private" : false ,
5- "version" : " 1.0.4 " ,
5+ "version" : " 1.0.7 " ,
66 "description" : " A lightweight CSS-only scroll lock solution for iOS Safari and Android" ,
77 "type" : " module" ,
88 "main" : " dist/react-ios-scroll-lock.umd.js" ,
8383 "lint" : " eslint ." ,
8484 "preview" : " vite preview"
8585 },
86+ "peerDependencies" : {
87+ "react" : " >= 16.8.0" ,
88+ "react-dom" : " >= 16.8.0"
89+ },
8690 "devDependencies" : {
8791 "@eslint/js" : " ^9.21.0" ,
8892 "@types/node" : " ^22.13.10" ,
98102 "typescript-eslint" : " ^8.24.1" ,
99103 "vite" : " ^6.2.0" ,
100104 "vite-plugin-static-copy" : " ^2.3.0" ,
101- "react" : " ^19.0 .0" ,
102- "react-dom" : " ^19.0 .0" ,
105+ "react" : " >= 16.8 .0" ,
106+ "react-dom" : " >= 16.8 .0" ,
103107 "vite-plugin-dts" : " ^4.5.3"
104108 }
105109}
Original file line number Diff line number Diff line change 1- // import "./styles/ react-ios-scroll-lock.css" ;
2- import React from "react" ;
1+ import React , { useEffect } from ' react' ;
2+ import ( "./styles/styles.css" ) ;
33
44interface IosScrollLockProps {
55 bgColor ?: string ;
@@ -16,7 +16,28 @@ function IosScrollLock({
1616 className = "" ,
1717 bgColor = "" ,
1818} : IosScrollLockProps ) {
19- import ( "./styles/styles.css" ) ;
19+
20+ useEffect ( ( ) => {
21+ const isIOS =
22+ typeof window !== "undefined" &&
23+ navigator . userAgent . match ( / i P h o n e | i P a d | i P o d / i) ;
24+
25+ function setIOSHeight ( ) {
26+ document . documentElement . style . setProperty (
27+ "--isl-vh" ,
28+ window . innerHeight * 0.01 + "px"
29+ ) ;
30+ }
31+
32+ if ( isIOS ) {
33+ setIOSHeight ( ) ;
34+ window . addEventListener ( "resize" , setIOSHeight ) ;
35+
36+ return ( ) => {
37+ window . removeEventListener ( "resize" , setIOSHeight ) ;
38+ } ;
39+ }
40+ } , [ ] ) ;
2041
2142 const rootStyle = bgColor
2243 ? ( { "--isl-bg" : bgColor } as React . CSSProperties )
You can’t perform that action at this time.
0 commit comments