@@ -215,7 +215,8 @@ var Scrollbar = function (_Component) {
215215 } ;
216216 } , _this . handleDragEnd = function ( ) {
217217 _this . drag = false ;
218- _this . dragPrevPageX = _this . dragPrevPageY = 0 ;
218+ _this . dragPrevPageX = undefined ;
219+ _this . dragPrevPageY = undefined ;
219220
220221 document . removeEventListener ( "mousemove" , _this . handleDragEvent ) ;
221222 document . removeEventListener ( "mouseup" , _this . handleDragEnd ) ;
@@ -226,13 +227,17 @@ var Scrollbar = function (_Component) {
226227 _this . thumbHorizontal . classList . remove ( "dragging" ) ;
227228 _this . thumbVertical . classList . remove ( "dragging" ) ;
228229 } , _this . handleDragEvent = function ( e ) {
229- if ( _this . dragPrevPageX ) {
230- var offset = - _this . trackHorizontal . getBoundingClientRect ( ) . left + e . clientX - ( _this . thumbHorizontal . clientWidth - _this . dragPrevPageX ) ;
231- _this . content . scrollLeft = _this . computeScrollLeftForThumbOffset ( offset ) ;
230+ if ( ! _this . drag ) {
231+ return ;
232+ }
233+
234+ if ( _this . dragPrevPageY !== undefined ) {
235+ var offset = - _this . trackVertical . getBoundingClientRect ( ) . top + e . clientY - ( _this . thumbVertical . clientHeight - _this . dragPrevPageY ) ;
236+ _this . content . scrollTop = _this . computeScrollTopForThumbOffset ( offset ) ;
232237 }
233- if ( _this . dragPrevPageY ) {
234- var _offset = - _this . trackVertical . getBoundingClientRect ( ) . top + e . clientY - ( _this . thumbVertical . clientHeight - _this . dragPrevPageY ) ;
235- _this . content . scrollTop = _this . computeScrollTopForThumbOffset ( _offset ) ;
238+ if ( _this . dragPrevPageX !== undefined ) {
239+ var _offset = - _this . trackHorizontal . getBoundingClientRect ( ) . left + e . clientX - ( _this . thumbHorizontal . clientWidth - _this . dragPrevPageX ) ;
240+ _this . content . scrollLeft = _this . computeScrollLeftForThumbOffset ( _offset ) ;
236241 }
237242 } , _temp ) , _possibleConstructorReturn ( _this , _ret ) ;
238243 }
@@ -263,7 +268,18 @@ var Scrollbar = function (_Component) {
263268 }
264269 } , {
265270 key : "componentDidUpdate" ,
266- value : function componentDidUpdate ( ) {
271+ value : function componentDidUpdate ( prevProps ) {
272+ if ( prevProps . contentSizeTrack !== this . props . contentSizeTrack ) {
273+ if ( prevProps . contentSizeTrack ) {
274+ this . contentSizeTrackStop ( ) ;
275+ } else {
276+ this . contentSizeTrackStart ( ) ;
277+ }
278+ } else if ( this . props . contentSizeTrack && this . props . contentSizeTrackInterval !== prevProps . contentSizeTrackInterval ) {
279+ this . contentSizeTrackStop ( ) ;
280+ this . contentSizeTrackStart ( ) ;
281+ }
282+
267283 this . update ( ) ;
268284
269285 var _content = this . content ,
@@ -280,20 +296,6 @@ var Scrollbar = function (_Component) {
280296
281297 this . addListeners ( ) ;
282298 }
283- } , {
284- key : "componentWillUpdate" ,
285- value : function componentWillUpdate ( nextProps ) {
286- if ( nextProps . contentSizeTrack !== this . props . contentSizeTrack ) {
287- if ( nextProps . contentSizeTrack ) {
288- this . contentSizeTrackStart ( ) ;
289- } else {
290- this . contentSizeTrackStop ( ) ;
291- }
292- } else if ( nextProps . contentSizeTrack && nextProps . contentSizeTrackInterval !== this . props . contentSizeTrackInterval ) {
293- this . contentSizeTrackStop ( ) ;
294- this . contentSizeTrackStart ( ) ;
295- }
296- }
297299
298300 /**
299301 * @return {Scrollbar }
0 commit comments