Files
ai-resume/content/assets/code/02-js-easing-core.js

54 lines
2.2 KiB
JavaScript

// Excerpt from js/utils/text_effects.js (2,156 lines) in the WebsiteBuilder
// source. Two regions are reproduced verbatim: the timeline loop that derives
// each letter's delay from an easing function (lines 1111-1147), and the
// hand-written easing functions themselves (lines 1340-1349).
$(mySplitTextTarg).each(function(i){
tweenData.letter=$(this);
tweenData.text_static.letter=$(this);
tweenData.text_text_to.letter=$(this);
tweenData.text_text_from.letter=$(this);
if(text_effect_type_animation=="standard"){
if(tweenData.ignoreItems=="on" && Math.random()<tweenData.ignore_amount)return;
if(!keepHide(tweenData,i,$(this).text()))return;
var transforms=getTransforms(tweenData);
//currenttime,start,change,duration
if(tweenData.staggerTimeRnd=="random")stagger=min_max_random(0,tweenData.staggerTime);
// stagger=positionsCubic(tweenData.alternatecount, 0, tweenData.duration, tweenData.total)
var ease=tweenData.easeFunction;
// var ease="easeInCubic";
stime=tweenData.duration;
if(tweenData.direc=="in"){
stagger=jQuery.easing[ease](null,tweenData.alternatecount, 0, tweenData.duration, tweenData.total)+tweenData.startWait
transforms.delay=stagger;
TweenMax.from($(this), tweenData.duration, transforms);
tt=tweenData.duration+stagger;
}
if(tweenData.direc=="out"){
stagger=jQuery.easing[ease](null,tweenData.alternatecount, 0, tweenData.duration, tweenData.total)
transforms.delay=stagger;
transforms.onComplete=tweenRemove($(this),stagger+stime+tweenData.removeWait)
TweenMax.to($(this), tweenData.duration, transforms);
tt=tweenData.duration+stagger+tweenData.removeWait+1;
}
setCssTweens(stime,text_effect_type_animation,tweenData,tweenData.text_static,tweenData.text_text_to,tweenData.text_text_from,$(this),stagger);
// --- easing functions, lines 1340-1349 ---
//t,b,c,d
//currenttime,start,change,duration
//t and do can be time or frames
function positionsCubic(t, b, c, d){
t /= d;
return c*t*t*t + b;
}
function positionSine(t, b, c, d) {
return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
}