jeremyckahn / shifty

The fastest TypeScript animation engine on the web
https://jeremyckahn.github.io/shifty/doc/
MIT License
1.54k stars 88 forks source link

Should not be able to seek to a negative value #57

Closed ZainManji closed 9 years ago

ZainManji commented 9 years ago

If I enter a seek value less than 0, it should default to the properties specified at 0ms.

For example,

var tweenable = new Tweenable({}, { from: {opacity:0}, to: {opacity:1}, duration:100});
tweenable.seek(-10); //This should probably seek to the point where opacity = 0, but 
                     //what is happening is that opacity is now -0.1
jeremyckahn commented 9 years ago

Good call. I will roll a fix for this into the 1.3.7 release, which will be along shortly.

SBoudrias commented 9 years ago

@jeremyckahn I think the inverse bug would appear if you set seek to a value higher than the duration of the tweenable. Maybe also bound the value with a Math.min(millisecond, this.duration)?

jeremyckahn commented 9 years ago

@SBoudrias I was thinking about that, but it's actually a non-issue. The tween just naturally terminates when the seek millisecond is greater than the duration: http://codepen.io/jeremyckahn/pen/EaxXZK

It's a bit less explicit the way it is now, but I would prefer less code if possible.

SBoudrias commented 9 years ago

If it's not an issue than that seem fair to me. Thanks for being so reactive!