explore maps lists were rendering bajillions too many times causing everything to go slow. timeouts weren't canceling. very wow
This commit is contained in:
parent
5cf75f3ea2
commit
4ca12c70ab
5 changed files with 16 additions and 5 deletions
|
@ -176,14 +176,19 @@ Metamaps.Backbone.MapsCollection = Backbone.Collection.extend({
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
Metamaps.Loading.show();
|
||||||
|
|
||||||
if (this.page != "loadedAll") {
|
if (this.page != "loadedAll") {
|
||||||
var numBefore = this.length;
|
var numBefore = this.length;
|
||||||
this.fetch({
|
this.fetch({
|
||||||
remove: false,
|
remove: false,
|
||||||
|
silent: true,
|
||||||
data: { page: this.page },
|
data: { page: this.page },
|
||||||
success: function (collection, response, options) {
|
success: function (collection, response, options) {
|
||||||
// you can pass additional options to the event you trigger here as well
|
// you can pass additional options to the event you trigger here as well
|
||||||
if (collection.length - numBefore < 20) self.page = "loadedAll";
|
if (collection.length - numBefore < 20) {
|
||||||
|
self.page = "loadedAll";
|
||||||
|
}
|
||||||
else self.page += 1;
|
else self.page += 1;
|
||||||
self.trigger('successOnFetch');
|
self.trigger('successOnFetch');
|
||||||
},
|
},
|
||||||
|
|
|
@ -54,7 +54,8 @@
|
||||||
Metamaps.GlobalUI.Search.close(0, true);
|
Metamaps.GlobalUI.Search.close(0, true);
|
||||||
|
|
||||||
Metamaps.Famous.maps.hide();
|
Metamaps.Famous.maps.hide();
|
||||||
setTimeout(function(){
|
clearTimeout(Metamaps.routerTimeoutId);
|
||||||
|
Metamaps.routerTimeoutId = setTimeout(function(){
|
||||||
Metamaps.Router.navigate("");
|
Metamaps.Router.navigate("");
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,8 +91,9 @@ Metamaps.Views.init = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
Metamaps.Loading.hide();
|
Metamaps.Loading.hide();
|
||||||
|
Metamaps.Famous.maps.lock = false;
|
||||||
|
|
||||||
clearTimeout(Metamaps.routerTimeoutFunctionIds);
|
clearTimeout(Metamaps.routerTimeoutId);
|
||||||
Metamaps.routerTimeoutId = setTimeout((function(localCurrentPage){ return function(){
|
Metamaps.routerTimeoutId = setTimeout((function(localCurrentPage){ return function(){
|
||||||
var path = (Metamaps.currentSection == "") ? "" : "/explore/" + localCurrentPage;
|
var path = (Metamaps.currentSection == "") ? "" : "/explore/" + localCurrentPage;
|
||||||
|
|
||||||
|
|
|
@ -1716,7 +1716,8 @@ Metamaps.Visualize = {
|
||||||
hold();
|
hold();
|
||||||
|
|
||||||
// update the url now that the map is ready
|
// update the url now that the map is ready
|
||||||
setTimeout(function(){
|
clearTimeout(Metamaps.routerTimeoutId);
|
||||||
|
Metamaps.routerTimeoutId = setTimeout(function(){
|
||||||
var m = Metamaps.Active.Map;
|
var m = Metamaps.Active.Map;
|
||||||
var t = Metamaps.Active.Topic;
|
var t = Metamaps.Active.Topic;
|
||||||
|
|
||||||
|
|
|
@ -206,12 +206,15 @@ Metamaps.Famous.build = function () {
|
||||||
f.maps.mod.setTransform(Transform.translate(window.innerWidth, 94, 0));
|
f.maps.mod.setTransform(Transform.translate(window.innerWidth, 94, 0));
|
||||||
};
|
};
|
||||||
var mapsScroll = new Scrollview();
|
var mapsScroll = new Scrollview();
|
||||||
|
f.maps.lock = false;
|
||||||
mapsScroll._scroller.on('edgeHit', function(data){
|
mapsScroll._scroller.on('edgeHit', function(data){
|
||||||
if (data.position > 0 &&
|
if (!f.maps.lock &&
|
||||||
|
data.position > 0 &&
|
||||||
Metamaps.Views &&
|
Metamaps.Views &&
|
||||||
Metamaps.Views.exploreMaps &&
|
Metamaps.Views.exploreMaps &&
|
||||||
Metamaps.Views.exploreMaps.collection &&
|
Metamaps.Views.exploreMaps.collection &&
|
||||||
Metamaps.Views.exploreMaps.collection.page != "loadedAll") {
|
Metamaps.Views.exploreMaps.collection.page != "loadedAll") {
|
||||||
|
f.maps.lock = true;
|
||||||
Metamaps.Views.exploreMaps.collection.getMaps();
|
Metamaps.Views.exploreMaps.collection.getMaps();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue