@@ -242,12 +242,7 @@ var slimScroll = function(C, payload){
242242 setAttr ( i [ s ] , 'data-scrollbar' , '1' ) ;
243243 assignValues ( ) ;
244244
245- // Show the default scrollbar to get the scrollbar width
246- i [ w ] . style . overflow = "" ;
247- var scrollBarWidth = i [ w ] . offsetWidth - i [ w ] . clientWidth ;
248- // Stretching the inner container so that the default scrollbar is completely invisible
249- i [ w ] . style . right = - scrollBarWidth + "px" ;
250- _this . isSlimScrollInserted = true ;
245+ placeIt ( ) ;
251246 if ( payload . keepFocus ) {
252247 setAttr ( i [ w ] , 'tabindex' , '-1' ) ;
253248 i [ w ] . focus ( ) ;
@@ -264,25 +259,26 @@ var slimScroll = function(C, payload){
264259 removeSlimScroll ( ) ;
265260 return ; // don't do any further operations
266261 }
262+ } ,
263+
264+ placeIt = function ( ) {
265+ // Show the default scrollbar to get the scrollbar width
266+ i [ w ] . style . overflow = "" ;
267+ var scrollBarWidth = i [ w ] . offsetWidth - i [ w ] . clientWidth ;
268+ // Stretching the inner container so that the default scrollbar is completely invisible
269+ i [ w ] . style . right = - scrollBarWidth + "px" ;
270+ _this . isSlimScrollInserted = true ;
271+ if ( payload . keepFocus ) {
272+ setAttr ( i [ w ] , 'tabindex' , '-1' ) ;
273+ i [ w ] . focus ( ) ;
274+ }
267275 } ;
268276
269277 _this . resetValues = function ( ) {
270278 if ( Object . keys ( i ) . length ) {
271279 assignValues ( ) ;
272-
273- // => Adding same styles as already present in init function
274- // @TODO : need to remove this repeating code and make it reuasable
275- // remove overflow hidden
276- i [ w ] . style . overflow = '' ;
277-
278- var scrollBarWidth = i [ w ] . offsetWidth - i [ w ] . clientWidth ;
279- // Stretching the inner container so that the default scrollbar is completely invisible
280- i [ w ] . style . right = - scrollBarWidth + "px" ;
281- _this . isSlimScrollInserted = true ;
282- if ( payload . keepFocus ) {
283- setAttr ( i [ w ] , 'tabindex' , '-1' ) ;
284- i [ w ] . focus ( ) ;
285- }
280+
281+ placeIt ( ) ;
286282 }
287283 else {
288284 assignValues ( ) ;
0 commit comments