From 11c820a2ab2ffca51ac52274fca1ccb482655e24 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Thu, 9 Jul 2015 23:43:42 +0200 Subject: [PATCH 1/4] added zoomKey to apply zooming only when a specific key is down --- docs/timeline/index.html | 10 ++++++++++ lib/timeline/Range.js | 5 ++++- lib/timeline/optionsTimeline.js | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/timeline/index.html b/docs/timeline/index.html index a6665ec3..5b9ba8e2 100644 --- a/docs/timeline/index.html +++ b/docs/timeline/index.html @@ -907,6 +907,16 @@ function (option, path) { + + zoomKey + String + '' + Specifies whether the Timeline is only zoomed when an additional key is down. + Available values are '' (does not apply), 'altKey', 'ctrlKey', or 'metaKey'. + Only applicable when option moveable is set true. + + + zoomMax number diff --git a/lib/timeline/Range.js b/lib/timeline/Range.js index 11c33093..55ad2ae5 100644 --- a/lib/timeline/Range.js +++ b/lib/timeline/Range.js @@ -78,7 +78,7 @@ Range.prototype = new Component(); Range.prototype.setOptions = function (options) { if (options) { // copy the options that we know - var fields = ['direction', 'min', 'max', 'zoomMin', 'zoomMax', 'moveable', 'zoomable', 'activate', 'hiddenDates']; + var fields = ['direction', 'min', 'max', 'zoomMin', 'zoomMax', 'moveable', 'zoomable', 'activate', 'hiddenDates', 'zoomKey']; util.selectiveExtend(fields, this.options, options); if ('start' in options || 'end' in options) { @@ -474,6 +474,9 @@ Range.prototype._onMouseWheel = function(event) { // only zoom when the mouse is inside the current range if (!this._isInsideRange(event)) return; + + // only zoom when the according key is pressed and the zoom_key option is set + if (this.options.zoomKey && !event[this.options.zoomKey]) return; // retrieve delta var delta = 0; diff --git a/lib/timeline/optionsTimeline.js b/lib/timeline/optionsTimeline.js index 81585612..a6ebbc8d 100644 --- a/lib/timeline/optionsTimeline.js +++ b/lib/timeline/optionsTimeline.js @@ -113,6 +113,7 @@ let allOptions = { type: {string}, width: {string, number}, zoomable: {boolean}, + zoomKey: {string}, zoomMax: {number}, zoomMin: {number}, @@ -197,6 +198,7 @@ let configureOptions = { type: ['box', 'point', 'range', 'background'], width: '100%', zoomable: true, + zoomKey: ['ctrlKey', 'altKey', 'metaKey', ''], zoomMax: [315360000000000, 10, 315360000000000, 1], zoomMin: [10, 10, 315360000000000, 1] } From 1a3fa5bee48822ac13dd96dfe9d64a110cc9698f Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Thu, 9 Jul 2015 23:45:09 +0200 Subject: [PATCH 2/4] typo --- lib/timeline/Range.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/timeline/Range.js b/lib/timeline/Range.js index 55ad2ae5..5bf5d403 100644 --- a/lib/timeline/Range.js +++ b/lib/timeline/Range.js @@ -475,7 +475,7 @@ Range.prototype._onMouseWheel = function(event) { // only zoom when the mouse is inside the current range if (!this._isInsideRange(event)) return; - // only zoom when the according key is pressed and the zoom_key option is set + // only zoom when the according key is pressed and the zoomKey option is set if (this.options.zoomKey && !event[this.options.zoomKey]) return; // retrieve delta From adb5bcebced05c817072f9a5d8ab8b3fbb87e0eb Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Mon, 13 Jul 2015 15:41:05 +0200 Subject: [PATCH 3/4] fixed missing validation of available zoomKey option values --- lib/timeline/optionsTimeline.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/timeline/optionsTimeline.js b/lib/timeline/optionsTimeline.js index a6ebbc8d..da4c4803 100644 --- a/lib/timeline/optionsTimeline.js +++ b/lib/timeline/optionsTimeline.js @@ -113,7 +113,7 @@ let allOptions = { type: {string}, width: {string, number}, zoomable: {boolean}, - zoomKey: {string}, + zoomKey: {string: ['ctrlKey', 'altKey', 'metaKey', '']}, zoomMax: {number}, zoomMin: {number}, From d881052df34066f8ac21b38e0f6a9009190786df Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Mon, 13 Jul 2015 15:41:32 +0200 Subject: [PATCH 4/4] added zoomKey option to Graph2d, added missing docs --- docs/graph2d/index.html | 20 ++++++++++++++++++++ lib/timeline/optionsGraph2d.js | 2 ++ 2 files changed, 22 insertions(+) diff --git a/docs/graph2d/index.html b/docs/graph2d/index.html index 28025771..61621a0d 100644 --- a/docs/graph2d/index.html +++ b/docs/graph2d/index.html @@ -1026,6 +1026,26 @@ function (option, path) { The width of the timeline in pixels or as a percentage. + + zoomable + boolean + true + + Specifies whether the Timeline can be zoomed by pinching or scrolling in the window. + Only applicable when option moveable is set true. + + + + + zoomKey + String + '' + Specifies whether the Timeline is only zoomed when an additional key is down. + Available values are '' (does not apply), 'altKey', 'ctrlKey', or 'metaKey'. + Only applicable when option moveable is set true. + + + zoomMax Number diff --git a/lib/timeline/optionsGraph2d.js b/lib/timeline/optionsGraph2d.js index 40569248..c6dc0ddb 100644 --- a/lib/timeline/optionsGraph2d.js +++ b/lib/timeline/optionsGraph2d.js @@ -150,6 +150,7 @@ let allOptions = { }, width: {string, number}, zoomable: {boolean}, + zoomKey: {string: ['ctrlKey', 'altKey', 'metaKey', '']}, zoomMax: {number}, zoomMin: {number}, __type__: {object} @@ -251,6 +252,7 @@ let configureOptions = { start: '', width: '100%', zoomable: true, + zoomKey: ['ctrlKey', 'altKey', 'metaKey', ''], zoomMax: [315360000000000, 10, 315360000000000, 1], zoomMin: [10, 10, 315360000000000, 1] }