Hi everyone,
First of all, I just wanted to say thanks to Kirupa for the fantastic book ‘Learning React’ - easily the best programming book I’ve ever read. He does a great job at explaining concepts in a way that’s easy to understand. The book has been a pleasure to read!
Anyway, I’m experimenting with react-motion and trying to get it working with a Header component that I’m building.
While I’ve been able to change the state of my component using onScroll (all working fine) for some reason it’s not letting me update the transform: translateY property.
Here’s the render method:
render() {
var { Motion, spring } = ReactMotion;
var headerStyles = "pl2 pt4 pb3 flex flex-column bg-white w-100 mb4";
return (
<Motion style={{y: spring(this.headerIsSticky ? -100 : 0)}}>
{
({y}) => {
return (
<header className={headerStyles} onScroll={this.handleScroll} style={{ transform: "translateY(" + y + ")" }}>
Hello world
</header>
);
}
}
</Motion>
);
}
Could anyone please shed some light on what I’m doing wrong? Thanks!
Link to the Codepen
Link to the Kirupa post I’ve been following to do the react-motion stuff