File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " rc-scrollbars" ,
3- "version" : " 1.1.1 " ,
3+ "version" : " 1.1.2 " ,
44 "description" : " React scrollbars component" ,
55 "main" : " lib/index.js" ,
66 "scripts" : {
Original file line number Diff line number Diff line change 11import css from 'dom-css' ;
22
33let scrollbarWidth : number | undefined = undefined ;
4- let pxRatio : number = window . screen . availWidth / document . documentElement . clientWidth ;
4+ let pxRatio : number = getPxRatio ( ) ;
55
66export default function getScrollbarWidth ( ) {
77 /**
88 * Check zoom ratio. If it was changed, then it would update scrollbatWidth
99 */
10- const newPxRatio = window . screen . availWidth / document . documentElement . clientWidth ;
10+ const newPxRatio = getPxRatio ( ) ;
11+
1112 if ( pxRatio !== newPxRatio ) {
1213 scrollbarWidth = getScrollbarWidthFromDom ( ) ;
1314 }
@@ -42,3 +43,8 @@ function getScrollbarWidthFromDom() {
4243
4344 return result ;
4445}
46+
47+ function getPxRatio ( ) {
48+ if ( typeof window === 'undefined' ) return 1 ;
49+ return window . screen . availWidth / document . documentElement . clientWidth ;
50+ }
You can’t perform that action at this time.
0 commit comments