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:
Connor Turland 2015-01-30 20:49:30 -05:00
parent 5cf75f3ea2
commit 4ca12c70ab
5 changed files with 16 additions and 5 deletions

View file

@ -176,14 +176,19 @@ Metamaps.Backbone.MapsCollection = Backbone.Collection.extend({
var self = this;
Metamaps.Loading.show();
if (this.page != "loadedAll") {
var numBefore = this.length;
this.fetch({
remove: false,
silent: true,
data: { page: this.page },
success: function (collection, response, options) {
// 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;
self.trigger('successOnFetch');
},

View file

@ -54,7 +54,8 @@
Metamaps.GlobalUI.Search.close(0, true);
Metamaps.Famous.maps.hide();
setTimeout(function(){
clearTimeout(Metamaps.routerTimeoutId);
Metamaps.routerTimeoutId = setTimeout(function(){
Metamaps.Router.navigate("");
}, 500);
}

View file

@ -91,8 +91,9 @@ Metamaps.Views.init = function () {
}
Metamaps.Loading.hide();
Metamaps.Famous.maps.lock = false;
clearTimeout(Metamaps.routerTimeoutFunctionIds);
clearTimeout(Metamaps.routerTimeoutId);
Metamaps.routerTimeoutId = setTimeout((function(localCurrentPage){ return function(){
var path = (Metamaps.currentSection == "") ? "" : "/explore/" + localCurrentPage;

View file

@ -1716,7 +1716,8 @@ Metamaps.Visualize = {
hold();
// update the url now that the map is ready
setTimeout(function(){
clearTimeout(Metamaps.routerTimeoutId);
Metamaps.routerTimeoutId = setTimeout(function(){
var m = Metamaps.Active.Map;
var t = Metamaps.Active.Topic;

View file

@ -206,12 +206,15 @@ Metamaps.Famous.build = function () {
f.maps.mod.setTransform(Transform.translate(window.innerWidth, 94, 0));
};
var mapsScroll = new Scrollview();
f.maps.lock = false;
mapsScroll._scroller.on('edgeHit', function(data){
if (data.position > 0 &&
if (!f.maps.lock &&
data.position > 0 &&
Metamaps.Views &&
Metamaps.Views.exploreMaps &&
Metamaps.Views.exploreMaps.collection &&
Metamaps.Views.exploreMaps.collection.page != "loadedAll") {
f.maps.lock = true;
Metamaps.Views.exploreMaps.collection.getMaps();
}
});