Skip to content
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

[SMOKES] Dynamic VS Vector decision + Vector Infowindows / Tooltips #1624

Merged
merged 80 commits into from
Jun 5, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
adb3280
Wait until vis has been reloaded to render the view
Apr 4, 2017
e2b86a4
Fixed test
Apr 17, 2017
2be9ea1
Renamed variable
Apr 18, 2017
0f2c907
Merge remote-tracking branch 'origin/v4' into dynamic-raster-vs-vecto…
Apr 19, 2017
416a2dc
Merge branch 'render-view-after-first-reload' into dynamic-raster-vs-…
Apr 19, 2017
562ba88
leaflet-layer-view-factory decides whether to use raster or vector
Apr 19, 2017
312ad85
Improve tangram loading mechanism
donflopez Apr 19, 2017
1ba8b75
fix tests to handle the new async instance
donflopez Apr 19, 2017
6c78291
Added tests
Apr 19, 2017
70284d5
Use tangram.cartodb with the new async feature
donflopez Apr 20, 2017
9db7d49
Fix lint error
donflopez Apr 20, 2017
0523453
Added internal renderMode setting and implemented 'auto' mode.
Apr 20, 2017
fd24bcc
Examples
Apr 20, 2017
9e64e98
Point to cartodb/tangram.cartodb#master
Apr 20, 2017
fd9e5d6
Lint errors
Apr 20, 2017
20bb463
Change fake load event for a real ready event
donflopez Apr 21, 2017
14db76d
Log error
Apr 21, 2017
fdc660a
Moved shared behaviour to base class. Also "meta" attribute gets
Apr 21, 2017
649fc6a
Merge branch 'render-view-after-first-reload' of https://github.com/C…
Apr 21, 2017
6520a34
Revert "Change fake load event for a real ready event"
Apr 21, 2017
10100b7
Remove defer to make it works sync
donflopez Apr 24, 2017
8f44be6
Merge remote-tracking branch 'origin/v4' into render-view-after-first…
Apr 24, 2017
ff8c442
Revert "Remove defer to make it works sync"
Apr 24, 2017
abfe46f
Fixed torque layer views
Apr 24, 2017
f45af59
Add tooltip and infowindow behaviour to vector
donflopez Apr 26, 2017
f966d75
Add the correct index of the layer in the layergroup
donflopez Apr 26, 2017
fad80a5
Change filter by get from backbone
donflopez Apr 27, 2017
669cf3d
Fix webgl tests
donflopez Apr 27, 2017
25de3a2
Merge remote-tracking branch 'origin/render-view-after-first-reload' …
Apr 27, 2017
a9d2340
Fix lint errors
donflopez Apr 27, 2017
65385c3
Merge pull request #1630 from CartoDB/vector-tooltips-infowindow
donflopez Apr 27, 2017
f9ef38a
Fixed test
Apr 27, 2017
64cf185
Increased max number of features supported by vector rendering
Apr 27, 2017
1358c3f
Change tangram.cartodb branch for testing purpose
donflopez Apr 28, 2017
5c86e24
Lint errors
Apr 28, 2017
2dba253
Merge pull request #1627 from CartoDB/dynamic-raster-vs-vector-decisi…
pabletecodes Apr 28, 2017
5356c77
Merge branch 'render-view-after-first-reload' of github.com:CartoDB/c…
donflopez Apr 28, 2017
224244e
window.webGLRenderingContext -> window.WebGLRenderingContext
May 3, 2017
61f698a
Merge branch 'render-view-after-first-reload' of github.com:CartoDB/c…
donflopez May 3, 2017
d8422f7
Fix invalid array index
donflopez May 3, 2017
e9b825a
Send features
donflopez May 3, 2017
3e3397c
Fix layer wrong index access
donflopez May 3, 2017
c93c5e8
Add buffer size 0 for mvt
donflopez May 4, 2017
4bc6542
Merge pull request #1635 from CartoDB/SMOKES-render-view-after-first-…
donflopez May 4, 2017
af63c13
Add performance metrics ⌛️
donflopez May 8, 2017
6eee256
Use flag to send only one time
donflopez May 9, 2017
851dd17
Merge remote-tracking branch 'origin/v4' into render-view-after-first…
May 10, 2017
9d2dff3
Merge branch 'render-view-after-first-reload' of https://github.com/C…
May 10, 2017
8106606
Estimated number of features per layer
May 11, 2017
96a58ae
Merge pull request #1641 from CartoDB/send-stats
donflopez May 11, 2017
26ceb1b
Conditional
May 11, 2017
fe83f5c
Lint errors
May 11, 2017
2c4ddab
Merge branch 'render-view-after-first-reload' of https://github.com/C…
May 11, 2017
11a8aea
Merge remote-tracking branch 'origin/v4' into render-view-after-first…
May 11, 2017
a4f80bf
Removed attr
May 12, 2017
4add424
Moved function to util "package"
May 12, 2017
361b8ff
Moving away from settingsModel to simplify things
May 12, 2017
92ed755
featureCount -> estimatedFeatureCount
May 12, 2017
ba5476b
Lint errors
May 12, 2017
9d21af1
node 6.9.2 in travis.yml
May 12, 2017
11a8998
Adds some more tests
May 15, 2017
53ddb65
Point to cartodb/tangram-carto#master
May 17, 2017
d5b4abc
Better error message
May 17, 2017
572b944
Even better error message
May 17, 2017
90c36a3
Merge remote-tracking branch 'origin/v4' into render-view-after-first…
May 23, 2017
dfa155a
Lint error
May 23, 2017
4f7742e
Set flyto feature
donflopez May 25, 2017
7c18975
Use load events for handling loading bar
donflopez May 29, 2017
a9343d3
this by self, context error
donflopez May 29, 2017
75ae033
Fix multiple set view
donflopez May 31, 2017
4fd5068
Merge branch 'render-view-after-first-reload' of github.com:CartoDB/c…
donflopez May 31, 2017
384787d
Add debounce for multiple calling
donflopez May 31, 2017
fb14178
Rely on moveend event instead of move event. No need to debounce
May 31, 2017
d775925
Use vector key from vizjson
Jun 1, 2017
0feca33
Missing file
Jun 1, 2017
7e37ffc
Merge branch 'v4' of github.com:CartoDB/cartodb.js into render-view-a…
donflopez Jun 2, 2017
0a70757
Set correct branch for tangram.cartodb
donflopez Jun 5, 2017
a87e098
Tests
Jun 5, 2017
f5daadb
Merge branch 'render-view-after-first-reload' of https://github.com/C…
Jun 5, 2017
604aae1
Lint errors
Jun 5, 2017
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
16 changes: 9 additions & 7 deletions src/geo/ui/legends/legends-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,15 @@ var LegendsView = View.extend({

_showOrHideShadows: function () {
var $el = $(this._container());
var currentPos = $el.scrollTop();
var max = $el.get(0).scrollHeight;
var height = $el.outerHeight();
var maxPos = max - height;

this.$shadowTop.toggleClass('is-visible', currentPos > 0);
this.$shadowBottom.toggleClass('is-visible', currentPos < maxPos);
if ($el.length) {
var currentPos = $el.scrollTop();
var max = $el.get(0).scrollHeight;
var height = $el.outerHeight();
var maxPos = max - height;

this.$shadowTop.toggleClass('is-visible', currentPos > 0);
this.$shadowBottom.toggleClass('is-visible', currentPos < maxPos);
}
},

_onScrollBottom: function () {
Expand Down
2 changes: 1 addition & 1 deletion src/vis/vis-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var OverlaysView = require('../geo/ui/overlays-view');
*/
var Vis = View.extend({
initialize: function (options) {
this.model.once('load', this.render, this);
this.model.once('reloaded', this.render, this);
this.model.on('invalidateSize', this._invalidateSize, this);

this._overlaysCollection = this.model.overlaysCollection;
Expand Down
16 changes: 12 additions & 4 deletions test/spec/api/create-vis.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,21 @@ describe('src/api/create-vis', function () {
this.container = $('<div id="map">').css('height', '200px');
this.containerId = this.container[0].id;
$('body').append(this.container);

this.$ajax = $.ajax;
spyOn($, 'ajax').and.callFake(function (options) {
if (options.url.indexOf(options.url.indexOf('http://cdb.localhost.lan:8181/api/v1/map/named/tpl_6a31d394_7c8e_11e5_8e42_080027880ca6/jsonp?') === 0)) {
options.success && options.success({
layergroupid: '1234567890'
});
}

this.$ajax(options);
}.bind(this));
});

afterEach(function () {
$.ajax = this.$ajax;
this.container.remove();
});

Expand Down Expand Up @@ -255,10 +267,6 @@ describe('src/api/create-vis', function () {
};

describe('map instantiation', function () {
beforeEach(function () {
spyOn($, 'ajax');
});

it('should instantiate map using a GET request', function (done) {
this.vis = createVis(this.containerId, fakeVizJSON, {});

Expand Down
89 changes: 38 additions & 51 deletions test/spec/vis/vis-view.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ VisView = VisView.extend({
}
});

var createVisView = function (container, visModel, settingsModel) {
var options = {
el: container,
widgets: new Backbone.Collection(),
model: visModel,
settingsModel: settingsModel
};

return new VisView(options);
};

describe('vis/vis-view', function () {
beforeEach(function () {
this.container = $('<div>').css('height', '200px');
Expand Down Expand Up @@ -52,17 +63,7 @@ describe('vis/vis-view', function () {
showLayerSelector: true
});

this.createNewVis = function (attrs) {
attrs.widgets = new Backbone.Collection();
attrs.model = this.visModel;
attrs.settingsModel = this.settingsModel;
this.visView = new VisView(attrs);
return this.visView;
};

this.createNewVis({
el: this.container
});
this.visView = createVisView(this.container, this.visModel, this.settingsModel);

this.visModel.load(new VizJSON(this.mapConfig));
this.visView.render();
Expand All @@ -75,78 +76,64 @@ describe('vis/vis-view', function () {
describe('map provider', function () {
beforeEach(function () {
this.fakeMapViewFactory = this.visView._getMapViewFactory();
this.fakeMapViewFactory.createMapView.calls.reset();

this.visView.render();
});

it('should have created a LeafletMap by default', function () {
expect(this.fakeMapViewFactory.createMapView.calls.mostRecent().args[0]).toEqual('leaflet');
});

it('should create a gmaps when provider changes to leaflet', function () {
this.visModel.map.set('provider', 'something');
this.visModel.map.set('provider', 'leaflet');

this.visView.render();

expect(this.fakeMapViewFactory.createMapView.calls.mostRecent().args[0]).toEqual('leaflet');
});

it('should create a google maps map when provider is googlemaps', function () {
this.visModel.map.set('provider', 'something', { silent: true });
it('should create a re-create the map view using a new provider when it changes', function () {
this.visModel.map.set('provider', 'googlemaps');

this.visView.render();

expect(this.fakeMapViewFactory.createMapView.calls.mostRecent().args[0]).toEqual('googlemaps');

this.visModel.map.set('provider', 'leaflet');
expect(this.fakeMapViewFactory.createMapView.calls.mostRecent().args[0]).toEqual('leaflet');
});
});

it('should bind resize changes when map height is 0', function () {
var INVALIDATE_SIZE_WAIT_IN_MS = 160;

it('should center map to origin once when map height is 0 initially and window is resized', function () {
jasmine.clock().install();
spyOn(this.visModel, 'invalidateSize');

var container = $('<div>').css('height', '0');
var vis = this.createNewVis({ el: container });
spyOn(vis, '_onResize').and.callThrough();

this.visModel.load(new VizJSON(this.mapConfig));
this.visView = createVisView(container, this.visModel, this.settingsModel);

// Wait until view has been rendered after load
jasmine.clock().tick(10);
this.visView.render();

// First time the window is resized -> map is centered to origin
$(window).trigger('resize');

expect(vis._onResize).toHaveBeenCalled();
vis._onResize.calls.reset();

jasmine.clock().tick(160);
jasmine.clock().tick(INVALIDATE_SIZE_WAIT_IN_MS);

expect(this.visModel.invalidateSize).toHaveBeenCalled();

this.visModel.invalidateSize.calls.reset();

// Second time the window is resized -> map is NOT centered to origin

$(window).trigger('resize');
expect(vis._onResize).not.toHaveBeenCalled();

jasmine.clock().tick(INVALIDATE_SIZE_WAIT_IN_MS);

expect(this.visModel.invalidateSize).not.toHaveBeenCalled();
jasmine.clock().uninstall();
});

it('should NOT bind resize changes when map height is greater than 0', function () {
it('should NOT center map to origin when map height is greated than O initially and window is resized', function () {
jasmine.clock().install();
spyOn(this.visModel, 'invalidateSize');

var container = $('<div>').css('height', '200px');
var vis = this.createNewVis({el: container});
spyOn(vis, '_onResize').and.callThrough();
var container = $('<div>').css('height', '800px');
this.visView = createVisView(container, this.visModel, this.settingsModel);

this.visModel.load(new VizJSON(this.mapConfig));

// Wait until view has been rendered after load
jasmine.clock().tick(10);
this.visView.render();

// Window is resized by map is not centered since height hasn't changed
$(window).trigger('resize');

expect(vis._onResize).not.toHaveBeenCalled();

jasmine.clock().tick(160);
jasmine.clock().tick(INVALIDATE_SIZE_WAIT_IN_MS);

expect(this.visModel.invalidateSize).not.toHaveBeenCalled();
});
Expand Down