some-react-components / react-scrollchor

A React component for scroll to `#hash` links with smooth animations
ISC License
149 stars 24 forks source link

variable offset parameter in animation properties #8

Closed justdoitcode345 closed 7 years ago

justdoitcode345 commented 7 years ago

thx a lot for component, it's very helpful

Is it right that I can't set variable in offset parameter in animation object? I've tried to do so and it looks like component takes it only once during component build and ignore it changes after component did mount. It is a little strange that changing props don't cause component to rebuild.

I need it to make anchor view in the middle of screen instead of it's top part. Even if user will change browser window height. Thats why I need to use a variable.

<Scrollchor
    to={letter}
    key={letter}
    className={styles.listLettersItem}
    animate={{offset: this.state.offset}}>
    {letter}
</Scrollchor> 
bySabi commented 7 years ago

Maybe an API change is needed. Let me a couple of time to found a solution.

mightyplow commented 7 years ago

I recently fixed that because I also needed that. It sounded like @bySabi will release that soon. =)

bySabi commented 7 years ago

New release, 4.0.0 support changeable props

Thanks again @mightyplow :)

mightyplow commented 7 years ago

I'll test that, when I'm back at work on Monday.