Ai
1 Star 0 Fork 12

NextZero/dom.js

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
getScrollbarWidth.js 718 Bytes
Copy Edit Raw Blame History
import isElement from './isElement'
/**
* 获取浏览器或者 DOM 元素纵向滚动条的宽度
* ========================================================================
* @method getScrollbarWidth
* @since 1.4.0
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Window/innerWidth
* @return {number}
*/
const getScrollbarWidth = (el) => {
let innerWidth = 0
let clientWidth = 0
if (!el) {
innerWidth = window.innerWidth
clientWidth = document.documentElement.clientWidth
} else {
if (isElement(el)) {
innerWidth = el.offsetWidth
clientWidth = el.clientWidth
}
}
return innerWidth - clientWidth
}
export default getScrollbarWidth
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/nextzero/dom.js.git
git@gitee.com:nextzero/dom.js.git
nextzero
dom.js
dom.js
main

Search