easing of gotoandstop (flash-js migration)
hi ![]()
sos! (designer searching for help from coders).
i'm trying to build an animation, that interacts with user input: mousewheel, keyboard and touch. the idea disscussed previously in this thread:
https://forums.adobe.com/thread/2190958
now. i have a movieclip with animation on main stage, everything works fine(forward/backward etc.), but instead of straight motion, i want to implement some easing to scroll. every time, when i swipe, when i press key, or when i move mousewheel, i want my (stopped) animation move some frames forward/backward respectively with easing. i found some code, based on robert penner equations, but my knowlege isn't enough for implement it. any help will be appreciated.
yay. ![]()
document.addEventListener('mousewheel',f.bind(this));
document.addEventListener('DOMMouseScroll',f.bind(this));
document.addEventListener('keydown',k.bind(this));
var time = 0;
var diff = 30;
var minTime = 0;
var maxTime = 1000;
function easeInOutQuad(t, b, c, d) {
if ((t /= d / 2) < 1) return c / 2 * t * t + b;
return -c / 2 * ((--t) * (t - 2) - 1) + b;
}
function easing(){
for (var i = 0, len = diff; i <= len; i++) {
(function(s) {setTimeout(function() {console.log(s);}, time);})(i);
time = easeInOutQuad(i, minTime, maxTime, diff);
console.log(time);
}
}
function f(e){
if (e.wheelDelta > 0||e.detail>0){
easing();
this.mymc.gotoAndStop(this.mymc.currentFrame+s);
} else if(e.wheelDelta < 0||e.detail<0){
easing();
this.mymc.gotoAndStop(this.mymc.currentFrame-s)
}
}
function k(event){
if (event.which===37){this.mymc.gotoAndStop(this.mymc.currentFrame-1);}
if (event.which===39){this.mymc.gotoAndStop(this.mymc.currentFrame+1);}
}
**gives me .s from easing function "undefined".
