Skip to content

plotly_relayout on mapbox scroll #2709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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