Some ideas!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
animationWorklet.import('twitter-header-animator.js').then( _ => { | |
var anim = new WorkletAnimation('twitter-header', | |
[document.timeline, new ScrollingTimeline(scrollingElement, {/* options for timeline */})], | |
{ | |
targets : { | |
bar: element1, | |
avatar: [element2, element3], | |
}, | |
timing: { | |
duration: ....??? | |
} | |
}); | |
} | |
//In animation worklet | |
registerAnimator('twitter-header', class { | |
const easing = new EaseOutTiming(); | |
animate(timelines, targets) { | |
const time = timelines[0].currentTime; // [0...timeRange] | |
const progress = time / range; | |
targets.get("bar")[0].outputStuleMap.set("opacity", easing.value(progress)) | |
targets.get("avatar").forEach(avatar => { | |
avator.outputStuleMap.set("opacity", progress); | |
}) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment