kopia lustrzana https://github.com/robhawkes/vizicities
reload on hashchange
rodzic
82e8d76466
commit
005610dc7d
|
@ -41,6 +41,8 @@
|
|||
this.loop = undefined;
|
||||
|
||||
this.publish("addToDat", this, {name: "City", properties: ["init"]});
|
||||
|
||||
this.subscribe("hashchange", this.onHashchange);
|
||||
};
|
||||
|
||||
VIZI.City.prototype.init = function(options) {
|
||||
|
@ -57,8 +59,8 @@
|
|||
|
||||
var hash = window.location.hash.replace('#', '');
|
||||
var coordCheck = /^(\-?\d+(\.\d+)?),(\-?\d+(\.\d+)?)$/;
|
||||
if (coordCheck.test(hash) && !_.has(options, 'coords')) {
|
||||
options.coords = hash.split(',');
|
||||
if (coordCheck.test(hash)) {
|
||||
options.coords = hash.split(',').reverse();
|
||||
}
|
||||
|
||||
_.defaults(options, {
|
||||
|
@ -264,4 +266,9 @@
|
|||
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
VIZI.City.prototype.onHashchange = function(){
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
}());
|
|
@ -19,6 +19,11 @@
|
|||
self.publish("resize", event);
|
||||
}, false );
|
||||
|
||||
// Hash change
|
||||
window.addEventListener( "hashchange", function(event) {
|
||||
self.publish("hashchange", event);
|
||||
}, false );
|
||||
|
||||
return Q.fcall(function() {});
|
||||
};
|
||||
}());
|
Ładowanie…
Reference in New Issue