From dcacab0445b40149fbf2cd9fa039ea412341acdd Mon Sep 17 00:00:00 2001 From: Jon Funkhouser Date: Thu, 17 Mar 2022 22:19:18 -0700 Subject: [PATCH 01/11] disable polar rotation drag when dragmode = false --- src/plots/polar/polar.js | 15 +- test/jasmine/tests/polar_test.js | 292 +++++++++++++++++++++++++++++++ 2 files changed, 303 insertions(+), 4 deletions(-) diff --git a/src/plots/polar/polar.js b/src/plots/polar/polar.js index 30cc3f0608c..12100eae26f 100644 --- a/src/plots/polar/polar.js +++ b/src/plots/polar/polar.js @@ -1150,6 +1150,9 @@ proto.updateRadialDrag = function(fullLayout, polarLayout, rngIndex) { var radialDrag = dragBox.makeRectDragger(layers, className, 'crosshair', -bl2, -bl2, bl, bl); var dragOpts = {element: radialDrag, gd: gd}; + if(fullLayout.dragmode === false) { + dragOpts.dragmode = false; + } updateElement(d3.select(radialDrag), radialAxis.visible && innerRadius < radius, { transform: strTranslate(tx, ty) @@ -1295,10 +1298,14 @@ proto.updateAngularDrag = function(fullLayout) { var angularDrag = dragBox.makeDragger(layers, 'path', 'angulardrag', 'move'); var dragOpts = {element: angularDrag, gd: gd}; - d3.select(angularDrag) - .attr('d', _this.pathAnnulus(radius, radius + dbs)) - .attr('transform', strTranslate(cx, cy)) - .call(setCursor, 'move'); + if(fullLayout.dragmode === false) { + dragOpts.dragmode = false; + } else { + d3.select(angularDrag) + .attr('d', _this.pathAnnulus(radius, radius + dbs)) + .attr('transform', strTranslate(cx, cy)) + .call(setCursor, 'move'); + } function xy2a(x, y) { return Math.atan2(cyy + dbs - y, x - cxx - dbs); diff --git a/test/jasmine/tests/polar_test.js b/test/jasmine/tests/polar_test.js index 38418e6352e..1da52310a47 100644 --- a/test/jasmine/tests/polar_test.js +++ b/test/jasmine/tests/polar_test.js @@ -1146,6 +1146,298 @@ describe('Test polar interactions:', function() { .then(done, done.fail); }); + describe('dragmode === false', function() { + it('should not respond to drag interactions on plot area when dragmode === false', function(done) { + var fig = Lib.extendDeep({}, require('@mocks/polar_scatter.json')); + + fig.layout.dragmode = false; + + // to avoid dragging on hover labels + fig.layout.hovermode = false; + + // adjust margins so that middle of plot area is at 300x300 + // with its middle at [200,200] + fig.layout.width = 400; + fig.layout.height = 400; + fig.layout.margin = {l: 50, t: 50, b: 50, r: 50}; + + var mid = [200, 200]; + var resetNumber = 0; + + function _drag(p0, dp) { + var node = d3Select('.polar > .draglayer > .maindrag').node(); + return drag({node: node, dpos: dp, pos0: p0}); + } + + function _assertRange(rng, msg) { + expect(gd._fullLayout.polar.radialaxis.range).toBeCloseToArray(rng, 1, msg); + } + + function _assertBase(extra) { + var msg = 'base range' + (extra ? ' ' + extra : ''); + _assertRange([0, 11.1], msg); + } + + function _reset() { + resetNumber++; + + var extra = '(reset ' + resetNumber + ')'; + _assertBase(extra); + expect(eventCnts.plotly_doubleclick).toBe(0, 'doubleclick event #' + extra); + } + + _plot(fig) + .then(_assertBase) + .then(function() { return _drag(mid, [50, 50]); }) + .then(function() { + _assertBase('from center move toward bottom-right'); + }) + .then(delay(20)) + .then(function() { return _doubleClick(mid); }) + .then(delay(20)) + .then(_reset) + .then(function() { return _drag(mid, [-50, -50]); }) + .then(function() { + _assertBase('from center move toward top-left'); + }) + .then(delay(20)) + .then(function() { return _doubleClick(mid); }) + .then(delay(20)) + .then(_reset) + .then(function() { return _drag([mid[0] + 30, mid[0] - 30], [50, -50]); }) + .then(function() { + _assertBase('from quadrant #1 move top-right'); + }) + .then(delay(20)) + .then(function() { return _doubleClick(mid); }) + .then(delay(20)) + .then(_reset) + .then(function() { return _drag([345, 200], [-50, 0]); }) + .then(function() { + _assertBase('from right edge move left'); + }) + .then(delay(20)) + .then(function() { return _doubleClick(mid); }) + .then(delay(20)) + .then(_reset) + .then(function() { return _drag(mid, [10, 10]);}) + .then(function() { _assertBase('from center to not far enough'); }) + .then(function() { return _drag([mid[0] + 30, mid[0] - 30], [-10, 0]);}) + .then(function() { _assertBase('from quadrant #1 to not far enough'); }) + .then(function() { return _drag([345, 200], [-10, 0]);}) + .then(function() { _assertBase('from right edge to not far enough'); }) + .then(function() { + expect(eventCnts.plotly_relayout) + .toBe(0, 'no new relayout events after *not far enough* cases'); + }) + .then(delay(20)) + .then(function() { return _doubleClick(mid); }) + .then(delay(20)) + .then(_reset) + .then(function() { return Plotly.relayout(gd, 'polar.hole', 0.2); }) + .then(function() { return _drag([mid[0] + 30, mid[0] - 30], [50, -50]); }) + .then(function() { + _assertRange([0, 11.4], 'with polar.hole>0, from quadrant #1 move top-right'); + }) + .then(done, done.fail); + }); + + it('should not respond to drag interactions on radial drag area when dragmode === false', function(done) { + var fig = Lib.extendDeep({}, require('@mocks/polar_scatter.json')); + + fig.layout.dragmode = false; + + // to avoid dragging on hover labels + fig.layout.hovermode = false; + + // adjust margins so that middle of plot area is at 300x300 + // with its middle at [200,200] + fig.layout.width = 400; + fig.layout.height = 400; + fig.layout.margin = {l: 50, t: 50, b: 50, r: 50}; + + var dragPos0 = [375, 200]; + var resetNumber = 0; + + // use 'special' drag method - as we need two mousemove events + // to activate the radial drag mode + function _drag(p0, dp) { + var node = d3Select('.polar > .draglayer > .radialdrag').node(); + return drag({node: node, dpos: dp, pos0: p0, nsteps: 2}); + } + + function _assert(rng, angle, evtRng1, evtAngle, msg) { + expect(gd._fullLayout.polar.radialaxis.range) + .toBeCloseToArray(rng, 1, msg + ' - range'); + expect(gd._fullLayout.polar.radialaxis.angle) + .toBeCloseTo(angle, 1, msg + ' - angle'); + + if(evtRng1 !== null) { + expect(eventData['polar.radialaxis.range[1]']) + .toBeCloseTo(evtRng1, 1, msg + ' - range[1] event data'); + } + if(evtAngle !== null) { + expect(eventData['polar.radialaxis.angle']) + .toBeCloseTo(evtAngle, 1, msg + ' - angle event data'); + } + } + + function _assertBase(extra) { + extra = extra ? ' ' + extra : ''; + _assert([0, 11.1], 0, null, null, 'base' + extra); + } + + function _reset() { + return delay(100)() + .then(function() { return _doubleClick([200, 200]); }) + .then(function() { + resetNumber++; + + var extra = '(reset ' + resetNumber + ')'; + _assertBase(extra); + expect(eventCnts.plotly_doubleclick).toBe(0, 'doubleclick event #' + extra); + }); + } + + _plot(fig) + .then(_assertBase) + .then(function() { return _drag(dragPos0, [-50, 0]); }) + .then(function() { + _assertBase('move inward'); + }) + .then(_reset) + .then(function() { return _drag(dragPos0, [50, 0]); }) + .then(function() { + _assertBase('move outward'); + }) + .then(_reset) + .then(function() { return _drag(dragPos0, [0, -50]); }) + .then(function() { + _assertBase('move counterclockwise'); + }) + .then(_reset) + .then(function() { return _drag(dragPos0, [0, 50]); }) + .then(function() { + _assertBase('move clockwise'); + }) + .then(_reset) + .then(function() { + expect(eventCnts.plotly_relayout).toBe(0, 'total # of relayout events'); + }) + .then(done, done.fail); + }); + + it('should not responsd to drag interactions on inner radial drag area when dragmode === false', function(done) { + var fig = Lib.extendDeep({}, require('@mocks/polar_scatter.json')); + fig.layout.dragmode = false; + fig.layout.polar.hole = 0.2; + // to avoid dragging on hover labels + fig.layout.hovermode = false; + // adjust margins so that middle of plot area is at 300x300 + // with its middle at [200,200] + fig.layout.width = 400; + fig.layout.height = 400; + fig.layout.margin = {l: 50, t: 50, b: 50, r: 50}; + + var dragPos0 = [200, 200]; + + // use 'special' drag method - as we need two mousemove events + // to activate the radial drag mode + function _drag(p0, dp) { + var node = d3Select('.polar > .draglayer > .radialdrag-inner').node(); + return drag({node: node, dpos: dp, pos0: p0, nsteps: 2}); + } + + function _assert(rng, msg) { + expect(gd._fullLayout.polar.radialaxis.range) + .toBeCloseToArray(rng, 1, msg + ' - range'); + } + + function _assertBase(extra) { + extra = extra ? ' ' + extra : ''; + _assert([0, 11.4], 'base' + extra); + } + + _plot(fig) + .then(function() { return _drag(dragPos0, [-50, 0]); }) + .then(function() { + _assertBase('move inward'); + }) + .then(function() { return Plotly.relayout(gd, 'polar.radialaxis.autorange', true); }) + .then(function() { return _drag(dragPos0, [50, 0]); }) + .then(function() { + _assertBase('move outward'); + }) + .then(done, done.fail); + }); + + it('should not responsd to drag interactions on angular drag area when dragmode === false', function(done) { + var fig = Lib.extendDeep({}, require('@mocks/polar_scatter.json')); + + fig.layout.dragmode = false; + + // to avoid dragging on hover labels + fig.layout.hovermode = false; + + // adjust margins so that middle of plot area is at 300x300 + // with its middle at [200,200] + fig.layout.width = 400; + fig.layout.height = 400; + fig.layout.margin = {l: 50, t: 50, b: 50, r: 50}; + + var dragPos0 = [350, 150]; + var resetNumber = 0; + + function _drag(p0, dp) { + var node = d3Select('.polar > .draglayer > .angulardrag').node(); + return drag({node: node, dpos: dp, pos0: p0}); + } + + function _assert(rot, msg, noEvent) { + expect(gd._fullLayout.polar.angularaxis.rotation) + .toBeCloseTo(rot, 1, msg + ' - rotation'); + if(!noEvent) { + expect(eventData['polar.angularaxis.rotation']) + .toBeCloseTo(rot, 1, msg + ' - rotation event data'); + } + } + + function _assertBase(extra) { + extra = extra ? ' ' + extra : ''; + _assert(0, 'base' + extra, true); + } + + function _reset() { + return delay(100)() + .then(function() { return _doubleClick([200, 200]); }) + .then(function() { + resetNumber++; + + var extra = '(reset ' + resetNumber + ')'; + _assertBase(extra); + expect(eventCnts.plotly_doubleclick).toBe(0, 'doubleclick event #' + extra); + }); + } + + _plot(fig) + .then(_assertBase) + .then(function() { return _drag(dragPos0, [-20, -20]); }) + .then(function() { + _assertBase('move counterclockwise'); + }) + .then(_reset) + .then(function() { return _drag(dragPos0, [20, 20]); }) + .then(function() { + _assertBase('move clockwise'); + }) + .then(_reset) + .then(function() { + expect(eventCnts.plotly_relayout).toBe(0, 'total # of relayout events'); + }) + .then(done, done.fail); + }); + }); + describe('should update scene during drag interactions on radial and angular drag area', function() { var objs = ['scatter2d', 'line2d']; var scene, gl, nTraces; From c52a352c82158fe56f52b16ecf75b0fec59c2824 Mon Sep 17 00:00:00 2001 From: Jon Funkhouser Date: Thu, 17 Mar 2022 22:26:26 -0700 Subject: [PATCH 02/11] log for PR 6147 --- draftlogs/6147_fix.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 draftlogs/6147_fix.md diff --git a/draftlogs/6147_fix.md b/draftlogs/6147_fix.md new file mode 100644 index 00000000000..62e8be8b1d3 --- /dev/null +++ b/draftlogs/6147_fix.md @@ -0,0 +1 @@ +- Disable polar rotation drag when dragmode = false [[#6147](https://github.com/plotly/plotly.js/pull/6147)] From 58e4bf9d5de7ebeb8ad993bbd01b07c7470da4c0 Mon Sep 17 00:00:00 2001 From: Jon Funkhouser Date: Wed, 4 May 2022 10:31:45 -0700 Subject: [PATCH 03/11] Update draftlogs/6147_fix.md Co-authored-by: Mojtaba Samimi <33888540+archmoj@users.noreply.github.com> --- draftlogs/6147_fix.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/draftlogs/6147_fix.md b/draftlogs/6147_fix.md index 62e8be8b1d3..24925680579 100644 --- a/draftlogs/6147_fix.md +++ b/draftlogs/6147_fix.md @@ -1 +1,2 @@ -- Disable polar rotation drag when dragmode = false [[#6147](https://github.com/plotly/plotly.js/pull/6147)] + - Fix for disabling polar rotation when `dragmode` is set to false [[#6147](https://github.com/plotly/plotly.js/pull/6147)], + with thanks to @jonfunkhouser for the contribution! From 6c1daf344b5257bdef1df4319856e012612d5baa Mon Sep 17 00:00:00 2001 From: Jon Funkhouser Date: Wed, 4 May 2022 15:26:15 -0700 Subject: [PATCH 04/11] trigger a relayout if dragmode changed to or from 'false' --- src/plot_api/plot_api.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index 5a459852837..abc86f8139a 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -2171,7 +2171,10 @@ function _relayout(gd, aobj) { if(parentFull.autorange) flags.calc = true; else flags.plot = true; } else { - if((fullLayout._has('scatter-like') && fullLayout._has('regl')) && + if(fullLayout._has('scatter-like') && ai === 'dragmode' && + ((vi === false && vOld !== false) || (vi !== false && vOld === false))) { + flags.plot = true; + } else if((fullLayout._has('scatter-like') && fullLayout._has('regl')) && (ai === 'dragmode' && (vi === 'lasso' || vi === 'select') && !(vOld === 'lasso' || vOld === 'select')) From 6a82dbbaa84dab76210a50ed1f85093f1b174f3f Mon Sep 17 00:00:00 2001 From: Jon Funkhouser Date: Fri, 6 May 2022 11:29:37 -0700 Subject: [PATCH 05/11] remove scatter-like check --- src/plot_api/plot_api.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index abc86f8139a..727ef1c9238 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -2171,8 +2171,7 @@ function _relayout(gd, aobj) { if(parentFull.autorange) flags.calc = true; else flags.plot = true; } else { - if(fullLayout._has('scatter-like') && ai === 'dragmode' && - ((vi === false && vOld !== false) || (vi !== false && vOld === false))) { + if(ai === 'dragmode' && ((vi === false && vOld !== false) || (vi !== false && vOld === false))) { flags.plot = true; } else if((fullLayout._has('scatter-like') && fullLayout._has('regl')) && (ai === 'dragmode' && From ea411d24dc5d4183410d9d901a56ca0db0950f85 Mon Sep 17 00:00:00 2001 From: Jon Funkhouser Date: Fri, 6 May 2022 11:30:01 -0700 Subject: [PATCH 06/11] remove existing event listeners --- src/components/dragelement/index.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/components/dragelement/index.js b/src/components/dragelement/index.js index 1f7c0e4d8d7..30d8c0ced1e 100644 --- a/src/components/dragelement/index.js +++ b/src/components/dragelement/index.js @@ -85,6 +85,23 @@ dragElement.init = function init(options) { initialTarget, rightClick; + if(options.dragmode === false) { + if(element.onmousedown) { + element.onmousedown = undefined; + } + if(!supportsPassive) { + if(element.ontouchstart) { + element.ontouchstart = undefined; + } + } else { + if(element._ontouchstart) { + element.removeEventListener('touchstart', element._ontouchstart); + element._ontouchstart = undefined; + } + } + return; + } + if(!gd._mouseDownTime) gd._mouseDownTime = 0; element.style.pointerEvents = 'all'; From 66aa0e87408488d8d188a9c2ca33811b0e5d692d Mon Sep 17 00:00:00 2001 From: Jon Funkhouser Date: Fri, 6 May 2022 15:57:35 -0700 Subject: [PATCH 07/11] Revert "remove existing event listeners" This reverts commit ea411d24dc5d4183410d9d901a56ca0db0950f85. --- src/components/dragelement/index.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/components/dragelement/index.js b/src/components/dragelement/index.js index 30d8c0ced1e..1f7c0e4d8d7 100644 --- a/src/components/dragelement/index.js +++ b/src/components/dragelement/index.js @@ -85,23 +85,6 @@ dragElement.init = function init(options) { initialTarget, rightClick; - if(options.dragmode === false) { - if(element.onmousedown) { - element.onmousedown = undefined; - } - if(!supportsPassive) { - if(element.ontouchstart) { - element.ontouchstart = undefined; - } - } else { - if(element._ontouchstart) { - element.removeEventListener('touchstart', element._ontouchstart); - element._ontouchstart = undefined; - } - } - return; - } - if(!gd._mouseDownTime) gd._mouseDownTime = 0; element.style.pointerEvents = 'all'; From b1fccb96a31efb2bac1b75d87d0287ca18063c73 Mon Sep 17 00:00:00 2001 From: Jon Funkhouser Date: Fri, 6 May 2022 15:59:05 -0700 Subject: [PATCH 08/11] fix typos --- test/jasmine/tests/polar_test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/jasmine/tests/polar_test.js b/test/jasmine/tests/polar_test.js index 1da52310a47..2ba4ac44767 100644 --- a/test/jasmine/tests/polar_test.js +++ b/test/jasmine/tests/polar_test.js @@ -961,7 +961,7 @@ describe('Test polar interactions:', function() { .then(done, done.fail); }); - it('should response to drag interactions on radial drag area', function(done) { + it('should respond to drag interactions on radial drag area', function(done) { var fig = Lib.extendDeep({}, require('@mocks/polar_scatter.json')); // to avoid dragging on hover labels @@ -1044,7 +1044,7 @@ describe('Test polar interactions:', function() { .then(done, done.fail); }); - it('should response to drag interactions on inner radial drag area', function(done) { + it('should respond to drag interactions on inner radial drag area', function(done) { var fig = Lib.extendDeep({}, require('@mocks/polar_scatter.json')); fig.layout.polar.hole = 0.2; // to avoid dragging on hover labels @@ -1082,7 +1082,7 @@ describe('Test polar interactions:', function() { .then(done, done.fail); }); - it('should response to drag interactions on angular drag area', function(done) { + it('should respond to drag interactions on angular drag area', function(done) { var fig = Lib.extendDeep({}, require('@mocks/polar_scatter.json')); // to avoid dragging on hover labels @@ -1327,7 +1327,7 @@ describe('Test polar interactions:', function() { .then(done, done.fail); }); - it('should not responsd to drag interactions on inner radial drag area when dragmode === false', function(done) { + it('should not respond to drag interactions on inner radial drag area when dragmode === false', function(done) { var fig = Lib.extendDeep({}, require('@mocks/polar_scatter.json')); fig.layout.dragmode = false; fig.layout.polar.hole = 0.2; @@ -1371,7 +1371,7 @@ describe('Test polar interactions:', function() { .then(done, done.fail); }); - it('should not responsd to drag interactions on angular drag area when dragmode === false', function(done) { + it('should not respond to drag interactions on angular drag area when dragmode === false', function(done) { var fig = Lib.extendDeep({}, require('@mocks/polar_scatter.json')); fig.layout.dragmode = false; From 92ae900cafb91975a47889194989034e6861ec1c Mon Sep 17 00:00:00 2001 From: Jon Funkhouser Date: Mon, 9 May 2022 12:09:26 -0700 Subject: [PATCH 09/11] apply suggestions --- src/plots/polar/polar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plots/polar/polar.js b/src/plots/polar/polar.js index 12100eae26f..5c359a8a15f 100644 --- a/src/plots/polar/polar.js +++ b/src/plots/polar/polar.js @@ -800,7 +800,7 @@ proto.updateHoverAndMainDrag = function(fullLayout) { var scaleX; var scaleY; - var mainDrag = dragBox.makeDragger(layers, 'path', 'maindrag', 'crosshair'); + var mainDrag = dragBox.makeDragger(layers, 'path', 'maindrag', fullLayout.dragmode === false ? 'none' : 'crosshair'); d3.select(mainDrag) .attr('d', _this.pathSubplot()) @@ -1295,7 +1295,7 @@ proto.updateAngularDrag = function(fullLayout) { var cyy = _this.cyy; var dbs = constants.angularDragBoxSize; - var angularDrag = dragBox.makeDragger(layers, 'path', 'angulardrag', 'move'); + var angularDrag = dragBox.makeDragger(layers, 'path', 'angulardrag', fullLayout.dragmode === false ? 'none' : 'move'); var dragOpts = {element: angularDrag, gd: gd}; if(fullLayout.dragmode === false) { From 1aa49ff55b53235e1326e3803da53cb0f2fe521f Mon Sep 17 00:00:00 2001 From: Jon Funkhouser Date: Mon, 9 May 2022 12:15:18 -0700 Subject: [PATCH 10/11] set dragmode via relayout() --- test/jasmine/tests/polar_test.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/test/jasmine/tests/polar_test.js b/test/jasmine/tests/polar_test.js index 2ba4ac44767..d3a58eeda06 100644 --- a/test/jasmine/tests/polar_test.js +++ b/test/jasmine/tests/polar_test.js @@ -1150,8 +1150,6 @@ describe('Test polar interactions:', function() { it('should not respond to drag interactions on plot area when dragmode === false', function(done) { var fig = Lib.extendDeep({}, require('@mocks/polar_scatter.json')); - fig.layout.dragmode = false; - // to avoid dragging on hover labels fig.layout.hovermode = false; @@ -1188,6 +1186,7 @@ describe('Test polar interactions:', function() { _plot(fig) .then(_assertBase) + .then(function() { return Plotly.relayout(gd, 'dragmode', false); }) .then(function() { return _drag(mid, [50, 50]); }) .then(function() { _assertBase('from center move toward bottom-right'); @@ -1228,7 +1227,7 @@ describe('Test polar interactions:', function() { .then(function() { _assertBase('from right edge to not far enough'); }) .then(function() { expect(eventCnts.plotly_relayout) - .toBe(0, 'no new relayout events after *not far enough* cases'); + .toBe(1, 'no new relayout events after *not far enough* cases'); }) .then(delay(20)) .then(function() { return _doubleClick(mid); }) @@ -1245,8 +1244,6 @@ describe('Test polar interactions:', function() { it('should not respond to drag interactions on radial drag area when dragmode === false', function(done) { var fig = Lib.extendDeep({}, require('@mocks/polar_scatter.json')); - fig.layout.dragmode = false; - // to avoid dragging on hover labels fig.layout.hovermode = false; @@ -1301,6 +1298,7 @@ describe('Test polar interactions:', function() { _plot(fig) .then(_assertBase) + .then(function() { return Plotly.relayout(gd, 'dragmode', false); }) .then(function() { return _drag(dragPos0, [-50, 0]); }) .then(function() { _assertBase('move inward'); @@ -1322,14 +1320,13 @@ describe('Test polar interactions:', function() { }) .then(_reset) .then(function() { - expect(eventCnts.plotly_relayout).toBe(0, 'total # of relayout events'); + expect(eventCnts.plotly_relayout).toBe(1, 'total # of relayout events'); }) .then(done, done.fail); }); it('should not respond to drag interactions on inner radial drag area when dragmode === false', function(done) { var fig = Lib.extendDeep({}, require('@mocks/polar_scatter.json')); - fig.layout.dragmode = false; fig.layout.polar.hole = 0.2; // to avoid dragging on hover labels fig.layout.hovermode = false; @@ -1359,6 +1356,8 @@ describe('Test polar interactions:', function() { } _plot(fig) + .then(_assertBase) + .then(function() { return Plotly.relayout(gd, 'dragmode', false); }) .then(function() { return _drag(dragPos0, [-50, 0]); }) .then(function() { _assertBase('move inward'); @@ -1374,8 +1373,6 @@ describe('Test polar interactions:', function() { it('should not respond to drag interactions on angular drag area when dragmode === false', function(done) { var fig = Lib.extendDeep({}, require('@mocks/polar_scatter.json')); - fig.layout.dragmode = false; - // to avoid dragging on hover labels fig.layout.hovermode = false; @@ -1421,6 +1418,7 @@ describe('Test polar interactions:', function() { _plot(fig) .then(_assertBase) + .then(function() { return Plotly.relayout(gd, 'dragmode', false); }) .then(function() { return _drag(dragPos0, [-20, -20]); }) .then(function() { _assertBase('move counterclockwise'); @@ -1432,7 +1430,7 @@ describe('Test polar interactions:', function() { }) .then(_reset) .then(function() { - expect(eventCnts.plotly_relayout).toBe(0, 'total # of relayout events'); + expect(eventCnts.plotly_relayout).toBe(1, 'total # of relayout events'); }) .then(done, done.fail); }); From 70cb931f2b6a10fb6bc301c095b66311a6995999 Mon Sep 17 00:00:00 2001 From: Jon Funkhouser Date: Mon, 9 May 2022 14:02:37 -0700 Subject: [PATCH 11/11] remove fig.layout.hovermode = false; --- test/jasmine/tests/polar_test.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/test/jasmine/tests/polar_test.js b/test/jasmine/tests/polar_test.js index d3a58eeda06..38832905ec9 100644 --- a/test/jasmine/tests/polar_test.js +++ b/test/jasmine/tests/polar_test.js @@ -1149,10 +1149,6 @@ describe('Test polar interactions:', function() { describe('dragmode === false', function() { it('should not respond to drag interactions on plot area when dragmode === false', function(done) { var fig = Lib.extendDeep({}, require('@mocks/polar_scatter.json')); - - // to avoid dragging on hover labels - fig.layout.hovermode = false; - // adjust margins so that middle of plot area is at 300x300 // with its middle at [200,200] fig.layout.width = 400; @@ -1243,10 +1239,6 @@ describe('Test polar interactions:', function() { it('should not respond to drag interactions on radial drag area when dragmode === false', function(done) { var fig = Lib.extendDeep({}, require('@mocks/polar_scatter.json')); - - // to avoid dragging on hover labels - fig.layout.hovermode = false; - // adjust margins so that middle of plot area is at 300x300 // with its middle at [200,200] fig.layout.width = 400; @@ -1328,8 +1320,6 @@ describe('Test polar interactions:', function() { it('should not respond to drag interactions on inner radial drag area when dragmode === false', function(done) { var fig = Lib.extendDeep({}, require('@mocks/polar_scatter.json')); fig.layout.polar.hole = 0.2; - // to avoid dragging on hover labels - fig.layout.hovermode = false; // adjust margins so that middle of plot area is at 300x300 // with its middle at [200,200] fig.layout.width = 400; @@ -1372,10 +1362,6 @@ describe('Test polar interactions:', function() { it('should not respond to drag interactions on angular drag area when dragmode === false', function(done) { var fig = Lib.extendDeep({}, require('@mocks/polar_scatter.json')); - - // to avoid dragging on hover labels - fig.layout.hovermode = false; - // adjust margins so that middle of plot area is at 300x300 // with its middle at [200,200] fig.layout.width = 400;