This commit is contained in:
Valentin Silytuin 2023-06-19 16:01:37 +04:00
commit 9f1c82f4d3
7 changed files with 154 additions and 0 deletions

8
.editorconfig Normal file
View File

@ -0,0 +1,8 @@
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

103
.gitignore vendored Executable file
View File

@ -0,0 +1,103 @@
# Настройки редакторов
.idea
.vscode
# Node.js
node_modules
# Yarn (https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored)
**/.pnp.*
**/.yarn/*
!**/.yarn/patches
!**/.yarn/plugins
!**/.yarn/releases
!**/.yarn/sdks
!**/.yarn/versions
# ESLint
.eslintcache
# Stylelint
.stylelintcache
# Composer
vendor
# https://github.com/github/gitignore/blob/master/Global/Linux.gitignore
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk

2
.npmignore Normal file
View File

@ -0,0 +1,2 @@
.editorconfig
.prettierrc

6
.prettierrc Normal file
View File

@ -0,0 +1,6 @@
{
"printWidth": 120,
"tabWidth": 4,
"singleQuote": true,
"bracketSpacing": false
}

7
README.md Normal file
View File

@ -0,0 +1,7 @@
# get-scrollbar-width
```js
import getScrollbarWidth from '@advdominion/get-scrollbar-width';
console.log(getScrollbarWidth());
```

17
index.js Normal file
View File

@ -0,0 +1,17 @@
export default () => {
if (document.body.clientHeight > window.innerHeight) {
const outer = document.createElement('div');
outer.style.visibility = 'hidden';
outer.style.width = '100px';
document.body.append(outer);
const widthNoScroll = outer.offsetWidth;
outer.style.overflow = 'scroll';
const inner = document.createElement('div');
inner.style.width = '100%';
outer.append(inner);
const widthWithScroll = inner.offsetWidth;
outer.remove();
return widthNoScroll - widthWithScroll;
}
return 0;
};

11
package.json Normal file
View File

@ -0,0 +1,11 @@
{
"name": "@advdominion/get-scrollbar-width",
"version": "1.0.0",
"type": "module",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://gitea.optiweb.ru/public/get-scrollbar-width.git"
},
"license": "MIT"
}