electerious / basicScroll

Standalone parallax scrolling for mobile and desktop with CSS variables.
https://basicscroll.electerious.com
MIT License
3.63k stars 148 forks source link

Error saying no 'elem' property has been provided when it has #60

Closed lavandalabs closed 4 years ago

lavandalabs commented 4 years ago

First off, amazing library. You've allowed some really next-level scroll-based animations for me and that is awesome.

I have this issue on React (17.0.1) where BasicScroll (3.0.3) is saying:

Error: Property 'from' must be a absolute value when no 'elem' has been provided

I'm using almost the exact same code from the guide. I've tried removing and reinstalling basicscroll, removing all npm packages, restarting, removing cache, etc..

Here's my code:

import * as basicScroll from 'basicscroll'

const imageGrow = basicScroll.create({
        elem: document.querySelector('.imageGrow'),
        from: 'top-bottom',
        to: 'middle-middle',
        props: {
            '--image-box-width': {
                from: '10%',
                to: '0'
            }
        }
})

imageGrow.start()

Thank you so much for any assistance you can provide!

lavandalabs commented 4 years ago

It was an issue with React functional components. The element wasn't rendered soon enough for the querySelector to return a valid element. Apologies for clouding your issues.