Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/issue 83 #84

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit $1
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
3 changes: 0 additions & 3 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run build
8 changes: 7 additions & 1 deletion README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
## 介绍
`tua-body-scroll-lock` 解决了所有场景下滚动穿透的问题。


- <a href="https://stackblitz.com/edit/js-vixsu9?file=index.js">
<img
width="160"
Expand Down Expand Up @@ -127,6 +126,13 @@ unlock()
```

### 选项
#### setOverflowForIOS: boolean(iOS lock only)

版本: `1.6.0+`
可选,默认值: `false`

适用于在 iOS 模拟器中阻止鼠标滚动事件。

#### overflowType: 'hidden' | 'clip'

可选,默认值: 'hidden'
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ unlock()
```

### Options
#### setOverflowForIOS: boolean (iOS lock only)

Version: `1.6.0+`
Optional, default: `false`

Used to prevent mouse scroll events in iOS simulator.

#### overflowType: 'hidden' | 'clip'

optional, default: 'hidden'
Expand All @@ -145,7 +152,7 @@ optional, default: false

Whether to use global `lockState` for every BSL. It's useful when your page have multiple BSL instances.

### TargetElement needs scrollingiOS only
### TargetElement needs scrolling (iOS only)
In some scenarios, when scrolling is prohibited, some elements still need to scroll, at this point, pass the targetElement.

```js
Expand Down
24 changes: 12 additions & 12 deletions examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
"preview": "vite preview"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"@typescript-eslint/eslint-plugin": "^5.61.0",
"@typescript-eslint/parser": "^5.61.0",
"@vitejs/plugin-react-swc": "^3.3.2",
"eslint": "^8.44.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.1",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@vitejs/plugin-react-swc": "^3.7.1",
"eslint": "^8.57.1",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.14",
"tua-body-scroll-lock": "workspace:*",
"typescript": "^5.0.2",
"vite": "^4.4.0"
"typescript": "^5.6.3",
"vite": "^4.5.5"
}
}
6 changes: 5 additions & 1 deletion examples/react/src/ModalOne.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export function ModalOne (props: {
useEffect(() => {
lock(
[targetOneRef.current!, targetTwoRef.current!],
{ overflowType: 'clip', useGlobalLockState: true },
{
overflowType: 'clip',
setOverflowForIOS: true,
useGlobalLockState: true,
},
)
return () => {
unlock(
Expand Down
4 changes: 2 additions & 2 deletions examples/vanilla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"devDependencies": {
"tua-body-scroll-lock": "workspace:*",
"typescript": "^5.0.2",
"vite": "^4.4.0"
"typescript": "^5.6.3",
"vite": "^4.5.5"
}
}
6 changes: 5 additions & 1 deletion examples/vanilla/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ const $targetThree = $<HTMLElement>('#targetThree')!
// show modals
$('#btn')!.addEventListener('click', () => {
$modalOne.style.display = 'block'
lock([$targetOne, $targetTwo], { overflowType: 'clip', useGlobalLockState: true })
lock([$targetOne, $targetTwo], {
overflowType: 'clip',
setOverflowForIOS: true,
useGlobalLockState: true,
})
})

$('#modalBtn')!.addEventListener('click', () => {
Expand Down
12 changes: 6 additions & 6 deletions examples/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
"preview": "vite preview"
},
"dependencies": {
"@vueuse/core": "^10.11.0",
"@vueuse/core": "^10.11.1",
"radash": "^12.1.0",
"vue": "^3.3.4"
"vue": "^3.5.12"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.2.3",
"@vitejs/plugin-vue": "^4.6.2",
"tua-body-scroll-lock": "workspace:*",
"typescript": "^5.0.2",
"vite": "^4.4.0",
"vue-tsc": "^1.8.3"
"typescript": "^5.6.3",
"vite": "^4.5.5",
"vue-tsc": "^1.8.27"
}
}
10 changes: 8 additions & 2 deletions examples/vue/src/ModalOne.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@ watch(() => props.visible, () => {
if (props.visible) {
lock(
[targetOneRef.value!, targetTwoRef.value!],
{ overflowType: 'clip', useGlobalLockState: props.useGlobalLockState },
{
overflowType: 'clip',
setOverflowForIOS: true,
useGlobalLockState: props.useGlobalLockState,
},
)
} else {
unlock(
[targetOneRef.value!, targetTwoRef.value!],
{ useGlobalLockState: props.useGlobalLockState },
{
useGlobalLockState: props.useGlobalLockState,
},
)
}
printLockedNum()
Expand Down
65 changes: 32 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tua-body-scroll-lock",
"version": "1.5.3",
"packageManager": "pnpm@^8",
"version": "1.6.0-beta.1",
"packageManager": "pnpm@9.12.3",
"description": "🔐Body scroll locking that just works with everything",
"main": "./dist/tua-bsl.umd.js",
"module": "./dist/tua-bsl.mjs",
Expand Down Expand Up @@ -55,44 +55,43 @@
]
},
"devDependencies": {
"@babel/core": "^7.24.0",
"@babel/preset-env": "^7.24.0",
"@babel/preset-typescript": "^7.23.3",
"@commitlint/cli": "^17.8.1",
"@commitlint/config-conventional": "^17.8.1",
"@babel/core": "^7.26.0",
"@babel/preset-env": "^7.26.0",
"@babel/preset-typescript": "^7.26.0",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-eslint": "^9.0.5",
"@rollup/plugin-replace": "^5.0.5",
"@rollup/plugin-replace": "^6.0.1",
"@rollup/plugin-terser": "^0.4.4",
"@types/jest": "^29.5.12",
"@types/node": "^20.11.25",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@vue/eslint-config-typescript": "^11.0.3",
"@types/jest": "^29.5.14",
"@types/node": "^22.8.6",
"@typescript-eslint/eslint-plugin": "^8.12.2",
"@typescript-eslint/parser": "^8.12.2",
"@vue/eslint-config-typescript": "^13",
"all-contributors-cli": "^6.26.1",
"babel-eslint": "^10.1.0",
"babel-jest": "^29.7.0",
"bumpp": "^9.4.0",
"concurrently": "^8.2.2",
"bumpp": "^9.8.0",
"concurrently": "^9.0.1",
"cross-env": "^7.0.3",
"eslint": "^8.57.0",
"eslint": "^8",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-vue": "^9.22.0",
"gh-pages": "^5.0.0",
"husky": "^8.0.3",
"eslint-plugin-promise": "^7.1.0",
"eslint-plugin-vue": "^9.30.0",
"gh-pages": "^6.2.0",
"husky": "^9.1.6",
"is-ci": "^3.0.1",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^13.3.0",
"rimraf": "^5.0.5",
"rollup": "^3.29.4",
"rollup-plugin-typescript2": "^0.35.0",
"typescript": "~5.0.4",
"vue-eslint-parser": "^9.4.2"
"lint-staged": "^15.2.10",
"rimraf": "^6.0.1",
"rollup": "^4.24.3",
"rollup-plugin-typescript2": "^0.36.0",
"typescript": "~5.6.3",
"vue-eslint-parser": "^9.4.3"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -125,12 +124,12 @@
"license": "MIT",
"pnpm": {
"overrides": {
"postcss@<8.4.31": ">=8.4.31",
"vite@>=4.4.0 <4.4.12": ">=4.4.12",
"@babel/traverse@<7.23.2": ">=7.23.2",
"@babel/traverse@<7.23.2": ">=7.25.9",
"postcss@<8.4.31": ">=8.4.47",
"semver@<5.7.2": ">=7.6.3",
"semver@>=6.0.0 <6.3.1": ">=6.3.1",
"vite@>=4.0.0 <=4.5.1": ">=4.5.2",
"semver@<5.7.2": ">=5.7.2",
"semver@>=6.0.0 <6.3.1": ">=6.3.1"
"vite@>=4.4.0 <4.4.12": ">=4.4.12"
}
}
}
Loading
Loading