Skip to content

Commit

Permalink
Merge pull request #2709 from plotly/mapbox-scroll
Browse files Browse the repository at this point in the history
plotly_relayout on mapbox scroll
  • Loading branch information
etpinard committed Jun 7, 2018
2 parents 95c88e6 + 6903320 commit f2478f9
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 284 deletions.
306 changes: 35 additions & 271 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"glslify": "^6.1.1",
"has-hover": "^1.0.1",
"has-passive-events": "^1.0.0",
"mapbox-gl": "0.44.1",
"mapbox-gl": "0.45.0",
"matrix-camera-controller": "^2.1.3",
"mouse-change": "^1.4.0",
"mouse-event-offset": "^3.0.2",
Expand Down
2 changes: 1 addition & 1 deletion src/plots/mapbox/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

'use strict';

var requiredVersion = '0.44.1';
var requiredVersion = '0.45.0';

module.exports = {
requiredVersion: requiredVersion,
Expand Down
9 changes: 8 additions & 1 deletion src/plots/mapbox/mapbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) {

if(self.isStatic) return;

var wheeling = false;

// keep track of pan / zoom in user layout and emit relayout event
map.on('moveend', function(eventData) {
if(!self.map) return;
Expand All @@ -149,11 +151,16 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) {
// mouse target (filtering out API calls) to not
// duplicate 'plotly_relayout' events.

if(eventData.originalEvent) {
if(eventData.originalEvent || wheeling) {
var update = {};
update[self.id] = Lib.extendFlat({}, view);
gd.emit('plotly_relayout', update);
}
wheeling = false;
});

map.on('wheel', function() {
wheeling = true;
});

map.on('mousemove', function(evt) {
Expand Down
Binary file modified test/image/baselines/mapbox_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_angles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_bubbles-text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_bubbles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_connectgaps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_custom-style.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_fill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_layers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_symbol-text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 17 additions & 10 deletions test/jasmine/tests/mapbox_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,14 @@ describe('@noCI, mapbox plots', function() {
doubleClickCnt++;
});

function _scroll(p) {
return new Promise(function(resolve) {
mouseEvent('mousemove', p[0], p[1]);
mouseEvent('scroll', p[0], p[1], {deltaY: -400});
setTimeout(resolve, 1000);
});
}

function assertLayout(center, zoom, opts) {
var mapInfo = getMapInfo(gd),
layout = gd.layout.mapbox;
Expand Down Expand Up @@ -858,14 +866,18 @@ describe('@noCI, mapbox plots', function() {
.then(function() {
expect(doubleClickCnt).toBe(1, 'double click cnt');
assertLayout([-4.710, 19.475], 1.234);

return _scroll(pointPos);
})
.then(function() {
expect(getMapInfo(gd).zoom).toBeGreaterThan(1.234);
expect(relayoutCnt).toBe(2);
})
.catch(failTest)
.then(done);

// TODO test scroll

}, LONG_TIMEOUT_INTERVAL);


it('should respond to click interactions by', function(done) {
var ptData;

Expand Down Expand Up @@ -1001,13 +1013,8 @@ describe('@noCI, mapbox plots', function() {
}

function _click(pos, cb) {
var promise = _mouseEvent('mousemove', pos, noop).then(function() {
return _mouseEvent('mousedown', pos, noop);
}).then(function() {
return _mouseEvent('click', pos, cb);
});

return promise;
mouseEvent('mousemove', pos[0], pos[1]);
return _mouseEvent('click', pos, cb);
}

function _doubleClick(pos) {
Expand Down

0 comments on commit f2478f9

Please sign in to comment.