Created
August 3, 2016 17:46
-
-
Save bfgeek/d194154ade7bd5c168e801d62f0c8e4c to your computer and use it in GitHub Desktop.
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
registerAnimator('parallax', class { | |
animate(inputs, outputs) { | |
// read scroller vertical scroll offset. | |
const scrollTop = inputs.scroller.scrollTop; | |
// update parallax transform | |
let t = outputs.parallax.styleMap.get('transform').m42; | |
t = -0.2 * scrollTop; | |
outputs.parallax.styleMap.set('transform', new CSSTransformValue(... t)); | |
} | |
}); | |
// Main thread. | |
const animator = new Animator('parallax', /* inputs dictionary */ { | |
'scroller': new AnimatorScrollSource(elem1), | |
}, /* outputs dictionary */ { | |
'parallax': new AnimatorStyle(elem2, ['transform']) | |
}); | |
animator.run(); | |
aniator.stop(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment