Skip to content

Commit

Permalink
chore: remove unused references getScrollbarWidth (#4650)
Browse files Browse the repository at this point in the history
* chore: remove unused references `getScrollbarWidth`

* chore: update common

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
RSS1102 and github-actions[bot] authored Oct 14, 2024
1 parent ad5a482 commit aa94731
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
13 changes: 0 additions & 13 deletions src/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,16 +378,3 @@ export function getWindowSize(): { width: number; height: number } {
const doc = document.documentElement;
return { width: doc.clientWidth, height: doc.clientHeight };
}

/**
* 计算滚动条宽度的方法
* 新建一个带有滚动条的 div 元素,通过该元素的 offsetWidth 和 clientWidth 的差值即可获得
*/
export function getScrollbarWidth() {
const scrollDiv = document.createElement('div');
scrollDiv.style.cssText = 'width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;';
document.body.appendChild(scrollDiv);
const scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
document.body.removeChild(scrollDiv);
return scrollbarWidth;
}

0 comments on commit aa94731

Please sign in to comment.