Skip to content

Commit c4ae90e

Browse files
committed
react-ios-scroll-lock ver 1.0.0
1 parent 91665bb commit c4ae90e

25 files changed

+2930
-1
lines changed

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist-ssr
12+
*.local
13+
14+
# Editor directories and files
15+
.vscode/*
16+
!.vscode/extensions.json
17+
.idea
18+
.DS_Store
19+
*.suo
20+
*.ntvs*
21+
*.njsproj
22+
*.sln
23+
*.sw?
24+
*.js

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore artifacts:
2+
build
3+
coverage

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Arsen Mkrtchyan
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,74 @@
11
# react-ios-scroll-lock
2-
ios-scroll-lock React Package
2+
3+
The initial idea was to lock the body scroll on iOS Safari whenever we see fit, turns out we made something that works everywhere on the web<br />This was achieved with overscroll-behaviour css property
4+
5+
### Medium Article:
6+
7+
### Demo: [https://stripearmy.github.io/ios-scroll-lock-demo/](https://stripearmy.github.io/ios-scroll-lock-demo/)
8+
9+
## Installation
10+
11+
$ npm install react-ios-scroll-lock
12+
or
13+
$ yarn add react-ios-scroll-lock
14+
15+
## Usage
16+
17+
```javascript
18+
// Import react-ios-scroll-lock
19+
import {IosScrollLock} from 'react-ios-scroll-lock';
20+
// Import css
21+
import 'react-ios-scroll-lock/css';
22+
23+
<IosScrollLock>
24+
Your content goes here
25+
</IosScrollLock>
26+
```
27+
28+
### Trigger the open state by modifying the "isOpen" (boolean) attribute <br /><br />Note: Is disabled by "isInline" attribute
29+
30+
```javascript
31+
<IosScrollLock isOpen={true}>
32+
```
33+
34+
### Tip: if your CSS breaks the functionality of IosScrollLock just render it using React Portal
35+
36+
```javascript
37+
{createPortal(
38+
<IosScrollLock isOpen={true}>
39+
Your content goes here
40+
</IosScrollLock>,
41+
document.body
42+
)}
43+
```
44+
45+
### Pass your custom className(s) by using the optional "className" attribute
46+
47+
```javascript
48+
<IosScrollLock className="yourCustomClassName">
49+
```
50+
51+
### Pass your custom background color by using the optional "bgColor" attribute
52+
53+
```javascript
54+
<IosScrollLock bgColor="#000">
55+
// or
56+
<IosScrollLock bgColor="rgba(0, 0, 0, 0.5)">
57+
// or
58+
<IosScrollLock bgColor="var(--yourCustomBgColor)">
59+
```
60+
61+
### Render the component contents ONLY wherever you want by using the optional "isInline" (boolean) attribute<br /><br />Note: Disables the effects of "isOpen" attribute
62+
63+
```javascript
64+
<IosScrollLock isInline={true}>
65+
```
66+
67+
## Contributing
68+
69+
Pull requests are welcome. For major changes, please open an issue first
70+
to discuss what you would like to change.
71+
72+
## License
73+
74+
[MIT](https://choosealicense.com/licenses/mit/)

dist/index.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { default as default_2 } from 'react';
2+
import { JSX } from 'react/jsx-runtime';
3+
4+
export declare function IosScrollLock({ children, isOpen, isInline, className, bgColor, }: IosScrollLockProps): JSX.Element;
5+
6+
declare interface IosScrollLockProps {
7+
bgColor?: string;
8+
isInline?: boolean;
9+
className?: string;
10+
isOpen?: boolean;
11+
children: default_2.ReactNode;
12+
}
13+
14+
export { }

dist/react-ios-scroll-lock.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)