@@ -89,8 +89,8 @@ export default function ScrollBar(options) {
8989 }
9090
9191 function setWidth ( width ) {
92- if ( isVertical ) $scrollbar . style . width = $cursor . style . width = width + "px" ;
93- else $scrollbar . style . height = $cursor . style . height = width + "px" ;
92+ if ( isVertical ) $scrollbar . style . width = $cursor . style . width = ` ${ width } px` ;
93+ else $scrollbar . style . height = $cursor . style . height = ` ${ width } px` ;
9494 }
9595
9696 /**
@@ -132,7 +132,7 @@ export default function ScrollBar(options) {
132132 else if ( top > height ) top = height ;
133133
134134 if ( currentTopValue !== top ) {
135- $cursor . style . top = top + "px" ;
135+ $cursor . style . top = ` ${ top } px` ;
136136 scroll = top / height ;
137137 if ( typeof $scrollbar . onScroll === "function" )
138138 $scrollbar . onScroll ( scroll ) ;
@@ -145,7 +145,7 @@ export default function ScrollBar(options) {
145145 else if ( left > width ) left = width ;
146146
147147 if ( currentLeftValue !== left ) {
148- $cursor . style . left = left + "px" ;
148+ $cursor . style . left = ` ${ left } px` ;
149149 scroll = left / width ;
150150 if ( typeof $scrollbar . onScroll === "function" )
151151 $scrollbar . onScroll ( scroll ) ;
@@ -180,16 +180,15 @@ export default function ScrollBar(options) {
180180 if ( render && height && width ) setValue ( scroll ) ;
181181 }
182182
183- function setValue ( val ) {
183+ function setValue ( value ) {
184184 if ( ! height || ! width ) resize ( false ) ;
185185
186186 //Make sure value is between 0 and 1
187- if ( val < 0 ) val = 0 ;
188- else if ( val > 1 ) val = 1 ;
187+ const boundedValue = Math . max ( 0 , Math . min ( 1 , value ) ) ;
189188
190- scroll = val ;
191- if ( isVertical ) $cursor . style . top = val * height + "px" ;
192- else $cursor . style . left = val * width + "px" ;
189+ scroll = boundedValue ;
190+ if ( isVertical ) $cursor . style . top = ` ${ boundedValue * height } px` ;
191+ else $cursor . style . left = ` ${ boundedValue * width } px` ;
193192 }
194193
195194 function destroy ( ) {
0 commit comments