-
Notifications
You must be signed in to change notification settings - Fork 37
animate features in maps.data #2
base: master
Are you sure you want to change the base?
Conversation
this.map = map; | ||
|
||
/** | ||
* Number of steps for the animation (higher # is smoother). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could I just set this to Number.MAX_VALUE? What's the trade-off? I assume performance but make a note here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to try render more than requestAnimationFrame, and sometimes users want relatively course/discrete steps thru the animation. Made a todo.
* Seconds the animation should last. | ||
* @type {number} | ||
*/ | ||
this.duration = 30; // seconds the aninmation should last. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JS devs really prefer their animation lengths in ms due to history of setTimeout, Date.now(), etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
The execution flow of animate is a little confusing right now, especially with currentTime being updated from the features themselves You'll also run into problems here with setTimeout clamping to 4ms. It seems like you also want it to always run as smoothly as possible, letting the browser's performance be the limiting factor. Really you just want to line up the range of times in the data itself and the range of time from the start of the animation to (start + duration). I think it would be clearer to rearrange the current code to first calculate how far you are into the animation range at the beginning, then map it to a time in the data range, and then loop over the features to see if they're before or after that time. This has the added benefit that setTimeout then becomes really easy to map to requestAnimationFrame, as you just run it util your animation progress is past 100% So something like (in pseudo-pseudo-code):
and then use one the requestAnimationFrame polyfills listed here for IE8/9: http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/ just a suggestion, but this approach seems clearer (to me, at least). |
That makes sense, but there's also the use case for a non-smooth animation On Wed, May 7, 2014 at 4:39 PM, Brendan Kenny notifications@github.comwrote:
|
Ah, good point. You can actually still achieve that by adding (though this depends on your definition of "number of steps" for an animation, as this gives an animation of |
Thanks makes sense. Done. |
|
||
/** | ||
* @constructor | ||
* @param {google.maps.Map} map features already loaded in map.data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth passing in map.data separately - can't people create separate Data objects?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but that's fairly (extremely?) rare; will add it to options anyone requests it.
* @type {number} | ||
*/ | ||
//TODO(jlivni): implement this. | ||
this.fadeSteps = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's more intuitive to express fading as a function of time, rather than steps, which are kind of like time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I am not sure. But since I have not implemented it I will just remove it for now and probably add back in later with option for time or steps.
* Milliseconds the animation should last. | ||
* @type {number} | ||
*/ | ||
this.duration = 30000; // ms the aninmation should last. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are still a heap of public properties that i'm pretty sure should be private, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other options private for reals now
No description provided.