From 77699b4fd9f321e1923d30766ca220d6414b6028 Mon Sep 17 00:00:00 2001 From: yotamberk Date: Mon, 1 May 2017 10:47:09 +0300 Subject: [PATCH] Eliminate repeatedly fired `rangechanged` events on mousewheel (#2989) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Add pausing of rangechanged in scroll --- lib/timeline/Range.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/timeline/Range.js b/lib/timeline/Range.js index f568bc58..0ae6dec0 100644 --- a/lib/timeline/Range.js +++ b/lib/timeline/Range.js @@ -196,12 +196,12 @@ Range.prototype.setRange = function(start, end, options, callback) { if (options.byUser !== true) { options.byUser = false; } + var me = this; var finalStart = start != undefined ? util.convert(start, 'Date').valueOf() : null; var finalEnd = end != undefined ? util.convert(end, 'Date').valueOf() : null; this._cancelAnimation(); if (options.animation) { // true or an Object - var me = this; var initStart = this.start; var initEnd = this.end; var duration = (typeof options.animation === 'object' && 'duration' in options.animation) ? options.animation.duration : 500; @@ -265,8 +265,12 @@ Range.prototype.setRange = function(start, end, options, callback) { byUser: options.byUser, event: options.event }; + this.body.emitter.emit('rangechange', params); - this.body.emitter.emit('rangechanged', params); + clearTimeout( me.timeoutID ); + me.timeoutID = setTimeout( function () { + me.body.emitter.emit('rangechanged', params); + }, 200 ); if (callback) { return callback() } } }