Skip to content

Commit

Permalink
bower/npm update
Browse files Browse the repository at this point in the history
  • Loading branch information
Edan Schwartz committed Apr 25, 2014
1 parent 5eaeac2 commit 499a435
Show file tree
Hide file tree
Showing 895 changed files with 52,735 additions and 238 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ define([
* @param {number} opt_options.timestep
* @param {number} opt_options.speed
* @param {number} opt_options.endDelay Milliseconds to pause between animation loops.
* @param {number} opt_options.opacity
*
* @constructor
* @class AbstractAnimation
Expand All @@ -24,7 +23,6 @@ define([
to: new Date().getTime(),
speed: 60 * 3,
timestep: 1000 * 60,
opacity: 1,
endDelay: 1000
});

Expand Down Expand Up @@ -112,16 +110,6 @@ define([
this.animationClock_ = null;


/**
* Opacity of animation tiles.
*
* @type {number}
* @private
* @property opacity_
*/
this.opacity_ = options.opacity;


AnimationInterface.call(this);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ define([

this.animations_ = _.without(this.animations_, animation);
animation.stop();
animation.remove();
};


Expand Down Expand Up @@ -326,17 +325,5 @@ define([
};


/**
* Sets the opacity for all sync'ed animations.
*
* @param {number} opacity
* @method setOpacity
*/
AnimationSync.prototype.setOpacity = function(opacity) {
_.each(this.animations_, function(anim) {
anim.setOpacity(opacity);
}, this);
};

return _.expose(AnimationSync, 'aeris.maps.animations.AnimationSync');
});
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ define([
*/
TimeLayersFactory.prototype.createLayerForTime_ = function(time) {
return this.baseLayer_.clone({
time: new Date(time)
time: new Date(time),
map: null
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ define([
* @constructor
* @extends aeris.maps.animations.AbstractAnimation
*
* @param {aeris.maps.layers.AerisTile} layer Base layer.
* @param {aeris.maps.layers.AerisTile} layer The layer to animate.
* @param {aeris.maps.animations.options.AnimationOptions} opt_options
* @param {number} opt_options.timestep Time between animation frames, in milliseconds.
* @param {aeris.maps.animations.helpers.AnimationLayerLoader=} opt_options.animationLayerLoader
Expand All @@ -23,27 +23,28 @@ define([
// Defaults will be set after times are loaded.
from: 0,
to: new Date().getTime(),
limit: 10
limit: 20
});

AbstractAnimation.call(this, options);


/**
* The layer which is being animated
* The original layer object, which will serve as
* the 'master' for all animation layer "frames."
*
* @type {aeris.maps.layers.AerisTile}
* @private
* @property baseLayer_
* @property masterLayer_
*/
this.baseLayer_ = layer;
this.masterLayer_ = layer;


/**
* A hash of {aeris.maps.layers.AerisTile},
* listed by timestamp.
*
* @type {Object}
* @type {Object.<number,aeris.maps.layers.AerisTile>}
* @private
* @property timeLayers_
*/
Expand All @@ -66,12 +67,13 @@ define([
* @type {aeris.animations.helpers.AnimationLayerLoader}
* @private
*/
this.animationLayerLoader_ = options.animationLayerLoader || new AnimationLayerLoader(this.baseLayer_, {
this.animationLayerLoader_ = options.animationLayerLoader || new AnimationLayerLoader(this.masterLayer_, {
from: this.from_,
to: this.to_,
limit: this.limit_
});

this.prepareMasterLayer_();
this.loadAnimationLayers();
};
_.inherits(TileAnimation, AbstractAnimation);
Expand All @@ -87,28 +89,50 @@ define([
* @method loadAnimationLayers
*/
TileAnimation.prototype.loadAnimationLayers = function() {
this.baseLayer_.set({
// Turn autoUpdate off, to prevent
// some funky behavior.
autoUpdate: false,

// All cloned layers should be hidden
opacity: 0
});

this.bindLoadEvents_();

this.animationLayerLoader_.once('load:times', function(times, timeLayers) {
this.setTimeLayers_(timeLayers);
this.updateTimeBounds_();
this.goToTime(this.to_);
this.trigger('load:times', times, timeLayers);

this.showInitialAnimationFrame_();
}, this);

return this.animationLayerLoader_.load();
};


/**
* Convert master layer into a "dummy" view model,
* with no bound rendering behavior.
*
* This will allow the client to manipulate the master layer
* as a proxy for all other animation frames, without actually
* showing the layer on the map.
*
* @method prepareMasterLayer_
* @private
*/
TileAnimation.prototype.prepareMasterLayer_ = function() {
// Destroy its strategy, so changes to its state are not rendered
this.masterLayer_.removeStrategy();
};


/**
* @method showInitialAnimationFrame_
* @private
*/
TileAnimation.prototype.showInitialAnimationFrame_ = function() {
var initialTime = this.to_;
var lastLayer = this.getLayerForTime_(initialTime);

this.goToTime(initialTime);
this.syncLayerToMaster_(lastLayer);
};


/**
* Animates to the layer at the next available time,
* or loops back to the start.
Expand Down Expand Up @@ -189,31 +213,20 @@ define([


/**
* Removes the animated layers from the map.
* @method remove
*/
TileAnimation.prototype.remove = function() {
this.stop();

_.invoke(this.timeLayers_, 'setOpacity', 0);
};


/**
* Sets the opacity of the animated
* layers.
* Destroys the tile animation object,
* clears animation frames from memory.
*
*
* @param {number} opacity
* @method setOpacity
* @method destroy
*/
TileAnimation.prototype.setOpacity = function(opacity) {
var currentLayer = this.getCurrentLayer();
TileAnimation.prototype.destroy = function() {
_.invoke(this.timeLayers_, 'destroy');
this.timeLayers_ = {};
this.times_.length = 0;

this.opacity_ = opacity;
this.stopListening();

if (currentLayer) {
currentLayer.setOpacity(this.opacity_);
}
this.masterLayer_.resetStrategy();
};


Expand Down Expand Up @@ -248,9 +261,50 @@ define([
};


/**
* Set the layer "frames" to animate.
*
* @method setTimeLayers_
* @param {Object.<number,aeris.maps.layers.AerisTile>} timeLayers Hash of timestamp --> layer
* @private
*/
TileAnimation.prototype.setTimeLayers_ = function(timeLayers) {
this.timeLayers_ = timeLayers;
this.times_ = this.getOrderedTimesFromLayers_(timeLayers);

_.each(timeLayers, this.initializeLayerLoading_, this);
};


/**
* Some mapping libraries will not load a layer
* until it has been set to the map.
*
* This method "quietly" sets a layer to the map,
* to make sure loading is initialized.
*
* @method initializeLayerLoading_
* @private
* @param {aeris.maps.layers.AerisTile} layer
*/
TileAnimation.prototype.initializeLayerLoading_ = function(layer) {
var quietlyAddToMap = (function() {
// Temporarily set to 0 opacity, so we don't see
// the layer being added to the map
layer.setOpacity(0);

// Trigger loading, by setting to the map
layer.setMap(this.masterLayer_.getMap());

// We're not going to be reset our layer attributes
// here because it (for some reason) causes the application
// to crash.
// Instead we'll rely on the transitioning logic.
// This may be dangerous, but it will work for now.
}).bind(this);

quietlyAddToMap();
this.listenTo(this.masterLayer_, 'map:set', quietlyAddToMap);
};


Expand Down Expand Up @@ -321,21 +375,40 @@ define([
* @method transition_
*/
TileAnimation.prototype.transition_ = function(oldLayer, newLayer) {
this.hideAllLayersExcept_(newLayer);

newLayer.setOpacity(this.opacity_);
};

this.syncLayerToMaster_(newLayer);

TileAnimation.prototype.hideAllLayersExcept_ = function(exceptLayer) {
// Sometime we have trouble with old layers sticking around.
// especially when we need to reload layers for new bounds.
// This a fail-proof way to handle that issue.
_.each(this.timeLayers_, function(layer) {
if (layer.cid !== exceptLayer.cid) {
layer.stop().hide();
if (layer !== newLayer) {
// Note that removing the old layer from the map
// every time causes performance issues.
layer.setOpacity(0);
layer.stopListening(this.masterLayer_);
}
}, this);
};


/**
* Update the attributes of the provided layer
* to match those of the master layer.
*
* @method syncLayerToMaster_
* @private
* @param {aeris.maps.layers.AerisTile} layer
*/
TileAnimation.prototype.syncLayerToMaster_ = function(layer) {
var boundAttrs = [
'map',
'opacity',
'zIndex'
];
layer.bindAttributesTo(this.masterLayer_, boundAttrs);
};


TileAnimation.prototype.getCurrentLayer = function() {
return this.getLayerForTime_(this.currentTime_);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,6 @@ define([
* Returns the object view,
* as rendered by the object's strategy.
*
* Note that a view may not be immediately
* available, if the objects strategy is being
* loaded asynchronously. For this reason, it is
* recommended to use #requestView, unless you know
* for certain that the object's strategy has been loaded.
*
* @throws {Error} If no strategy has been set on the object.
*
* @return {*}
Expand All @@ -137,38 +131,6 @@ define([
};


/**
* Request the view associated with
* this map object.
*
* Because the strategy used to render the view
* may be loaded asynchrously, this method allows you
* to request a object's view without knowing whether or
* not the strategy has been loaded.
*
* @return {aeris.Promise} Resolves with: {*} view.
* @method requestView
*/
MapExtensionObject.prototype.requestView = function() {
var promise = new Promise();

// Strategy is already loaded
// --> resolve immediately with view.
if (this.strategy_) {
promise.resolve(this.getView());
return promise;
}

// Wait for strategy to load
this.once('strategy:set', function(strategy) {
promise.resolve(this.getView());
}, this);


return promise;
};


/**
* @method destroy
*/
Expand Down
Loading

0 comments on commit 499a435

Please sign in to comment.