From 202a99724e1a3f50346e1071beb4b543bfb325d4 Mon Sep 17 00:00:00 2001 From: "MANEL-PC\\Manel" Date: Thu, 6 Aug 2020 18:02:36 +0200 Subject: [PATCH 1/4] Improved browser compatibility for table scroll --- src/traces/table/plot.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/traces/table/plot.js b/src/traces/table/plot.js index 9b2bddbed9f..645b0f16c99 100644 --- a/src/traces/table/plot.js +++ b/src/traces/table/plot.js @@ -57,13 +57,14 @@ module.exports = function plot(gd, wrappedTraceHolders) { .classed(c.cn.tableControlView, true) .style('box-sizing', 'content-box'); if(dynamic) { + let wheelEvent = 'onwheel' in document ? 'wheel' : 'mousewheel' cvEnter .on('mousemove', function(d) { tableControlView .filter(function(dd) {return d === dd;}) .call(renderScrollbarKit, gd); }) - .on('mousewheel', function(d) { + .on(wheelEvent, function(d) { if(d.scrollbarState.wheeling) return; d.scrollbarState.wheeling = true; var newY = d.scrollY + d3.event.deltaY; From 67c96d38c130d40bea2904c47c8a3e046439056f Mon Sep 17 00:00:00 2001 From: "MANEL-PC\\Manel" Date: Thu, 6 Aug 2020 18:42:46 +0200 Subject: [PATCH 2/4] Changed syntax to follow ES5 --- src/traces/table/plot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/traces/table/plot.js b/src/traces/table/plot.js index 645b0f16c99..aed2f799cf7 100644 --- a/src/traces/table/plot.js +++ b/src/traces/table/plot.js @@ -57,7 +57,7 @@ module.exports = function plot(gd, wrappedTraceHolders) { .classed(c.cn.tableControlView, true) .style('box-sizing', 'content-box'); if(dynamic) { - let wheelEvent = 'onwheel' in document ? 'wheel' : 'mousewheel' + var wheelEvent = 'onwheel' in document ? 'wheel' : 'mousewheel'; cvEnter .on('mousemove', function(d) { tableControlView From 7f983c5cc33fe3b2159417a01e2ec8614221421f Mon Sep 17 00:00:00 2001 From: "MANEL-PC\\Manel" Date: Fri, 7 Aug 2020 09:23:47 +0200 Subject: [PATCH 3/4] Changed the table scroll tests to use 'wheel' instead of 'mousewheel' --- test/jasmine/tests/table_test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jasmine/tests/table_test.js b/test/jasmine/tests/table_test.js index 408846a0f76..a98c546427d 100644 --- a/test/jasmine/tests/table_test.js +++ b/test/jasmine/tests/table_test.js @@ -415,7 +415,7 @@ describe('table', function() { gdWheelEventCount = 0; Plotly.plot(gd, mockCopy.data, mockCopy.layout) .then(function() { - gd.addEventListener('mousewheel', function(evt) { + gd.addEventListener('wheel', function(evt) { gdWheelEventCount++; // make sure we don't *really* scroll the page. // that would be annoying! @@ -440,7 +440,7 @@ describe('table', function() { function scroll(pos, dy) { mouseEvent('mousemove', pos.x, pos.y); - mouseEvent('mousewheel', pos.x, pos.y, {deltaX: 0, deltaY: dy}); + mouseEvent('wheel', pos.x, pos.y, {deltaX: 0, deltaY: dy}); } it('bubbles scroll events iff they did not scroll a table', function() { From 32d4fedae16babc5ecb777449ff5eaaf6f9909b4 Mon Sep 17 00:00:00 2001 From: "MANEL-PC\\Manel" Date: Fri, 7 Aug 2020 16:47:10 +0200 Subject: [PATCH 4/4] Changed 'mousewheel' event to 'wheel' in mouse_event.js --- test/jasmine/assets/mouse_event.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/jasmine/assets/mouse_event.js b/test/jasmine/assets/mouse_event.js index 21a85df7526..932a0ff16f6 100644 --- a/test/jasmine/assets/mouse_event.js +++ b/test/jasmine/assets/mouse_event.js @@ -36,10 +36,8 @@ module.exports = function(type, x, y, opts) { var el = (opts && opts.element) || document.elementFromPoint(x, y); var ev; - if(type === 'scroll' || type === 'mousewheel') { - // somehow table needs this to be mouswheel but others need wheel. - // yet they all work the same in the browser? - type = (type === 'scroll') ? 'wheel' : 'mousewheel'; + if(type === 'scroll' || type === 'wheel') { + type = 'wheel'; ev = new window.WheelEvent(type, Lib.extendFlat({}, fullOpts, opts)); } else { ev = new window.MouseEvent(type, fullOpts);