Created
August 3, 2016 17:51
-
-
Save bfgeek/f365eda80b08b9a0040b4267c3028731 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 { | |
static inputs = { | |
'scroller': ScrollSource; | |
}; | |
static outputs = { | |
'parallax': Style(['transform']) // This is bad. | |
} | |
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': elem1, | |
}, /* outputs dictionary */ { | |
'parallax': elem2, | |
}); | |
animator.run(); | |
aniator.stop(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment