From 482a259801e251c1abbd69825a2afeecdaece311 Mon Sep 17 00:00:00 2001 From: "konsvarl.work" Date: Fri, 15 Feb 2019 16:01:02 +0300 Subject: [PATCH 1/3] feature: add cluster.fitOnDoubleClick options --- docs/src/OptionsPage.js | 6 ++++++ examples/other/clustering.html | 3 ++- lib/timeline/component/item/ClusterItem.js | 6 ++++-- lib/timeline/optionsTimeline.js | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/src/OptionsPage.js b/docs/src/OptionsPage.js index 942b83f..911cd2c 100644 --- a/docs/src/OptionsPage.js +++ b/docs/src/OptionsPage.js @@ -693,6 +693,12 @@ class OptionsPage extends React.Component { {`false`} If true, line from cluster to time axis is displayed when content overflows. + + cluster.showStipes + boolean + {`false`} + If true, the cluster will be centered on double click. + snap diff --git a/examples/other/clustering.html b/examples/other/clustering.html index 5c5e7b4..466aa00 100644 --- a/examples/other/clustering.html +++ b/examples/other/clustering.html @@ -232,7 +232,8 @@ var clusterOpts = { cluster: { titleTemplate: "Cluster containing {count} events. Zoom in to see the individual events.", - showStipes: true + showStipes: true, + fitOnDoubleClick: true } }; Object.assign(options, defaultOptions, clusterOpts); diff --git a/lib/timeline/component/item/ClusterItem.js b/lib/timeline/component/item/ClusterItem.js index 9afbcd0..fb72df8 100644 --- a/lib/timeline/component/item/ClusterItem.js +++ b/lib/timeline/component/item/ClusterItem.js @@ -379,8 +379,10 @@ class ClusterItem extends Item { this.dom.dot.style.display = 'none'; } - this.dom.box.ondblclick = ClusterItem.prototype._onDoubleClick.bind(this); - + if (this.options.fitOnDoubleClick) { + this.dom.box.ondblclick = ClusterItem.prototype._onDoubleClick.bind(this); + } + // attach this item as attribute this.dom.box['timeline-item'] = this; diff --git a/lib/timeline/optionsTimeline.js b/lib/timeline/optionsTimeline.js index 318302d..fb57007 100644 --- a/lib/timeline/optionsTimeline.js +++ b/lib/timeline/optionsTimeline.js @@ -151,6 +151,7 @@ let allOptions = { titleTemplate: {'string': string, 'undefined': 'undefined'}, clusterCriteria: { 'function': 'function', 'undefined': 'undefined'}, showStipes: {'boolean': bool, 'undefined': 'undefined'}, + fitOnDoubleClick: {'boolean': bool, 'undefined': 'undefined'}, __type__: {'boolean': bool, object} }, snap: {'function': 'function', 'null': 'null'}, From 39cfb68ce2db0b9ca7a74f9c26a56041c8fc4e28 Mon Sep 17 00:00:00 2001 From: "konsvarl.work" Date: Mon, 18 Feb 2019 15:55:54 +0300 Subject: [PATCH 2/3] bugfix: fix 'fitOnDoubleClick' documantation --- docs/src/OptionsPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/OptionsPage.js b/docs/src/OptionsPage.js index 911cd2c..f5a4473 100644 --- a/docs/src/OptionsPage.js +++ b/docs/src/OptionsPage.js @@ -694,7 +694,7 @@ class OptionsPage extends React.Component { If true, line from cluster to time axis is displayed when content overflows. - cluster.showStipes + cluster.fitOnDoubleClick boolean {`false`} If true, the cluster will be centered on double click. From d2faa062a6044f303cf29143be859f1b59c8a0e8 Mon Sep 17 00:00:00 2001 From: "konsvarl.work" Date: Mon, 18 Feb 2019 16:16:52 +0300 Subject: [PATCH 3/3] chore: make fitOnDoubleClick true by default --- docs/src/OptionsPage.js | 2 +- examples/other/clustering.html | 1 - lib/timeline/component/item/ClusterItem.js | 4 +--- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/src/OptionsPage.js b/docs/src/OptionsPage.js index f5a4473..7dc2f75 100644 --- a/docs/src/OptionsPage.js +++ b/docs/src/OptionsPage.js @@ -696,7 +696,7 @@ class OptionsPage extends React.Component { cluster.fitOnDoubleClick boolean - {`false`} + {`true`} If true, the cluster will be centered on double click. diff --git a/examples/other/clustering.html b/examples/other/clustering.html index 466aa00..ffa7b08 100644 --- a/examples/other/clustering.html +++ b/examples/other/clustering.html @@ -233,7 +233,6 @@ cluster: { titleTemplate: "Cluster containing {count} events. Zoom in to see the individual events.", showStipes: true, - fitOnDoubleClick: true } }; Object.assign(options, defaultOptions, clusterOpts); diff --git a/lib/timeline/component/item/ClusterItem.js b/lib/timeline/component/item/ClusterItem.js index fb72df8..52355a3 100644 --- a/lib/timeline/component/item/ClusterItem.js +++ b/lib/timeline/component/item/ClusterItem.js @@ -24,9 +24,7 @@ class ClusterItem extends Item { }, }; - this.options = Object.assign({}, options, { - editable: false - }); + this.options = Object.assign({}, {fitOnDoubleClick: true}, options, {editable: false}); if (!data || data.uiItems == undefined) { throw new Error('Property "uiItems" missing in item ' + data.id);