davideperozzi / smoovy

A collection of small and useful js packages (smooth scrolling, router, parallax, webgl, utils, etc.) preventing copy & paste
MIT License
79 stars 8 forks source link

Cannot read property call of undefined #13

Closed davidstellini closed 4 years ago

davidstellini commented 4 years ago

I'm getting this error: vendor.js:formatted:17974 ERROR TypeError: Cannot read property 'call' of undefined

I tried it on both Smoovy 0.16, as well as 0.2.0.

One way to replicate it seems to be switching between responsive modes in chrome. image

This line in emitter.ts seems to be causing the problem. https://github.com/davideperozzi/smoovy/blob/c0a6e39ae7f7ef7ab1ad0955ade8db1a76fbc54d/packages/event/src/emitter.ts#L59

Even though listeners['recalc'].length is 1, it's trying to call the second callback [1].

I'm also getting: vendor.js:formatted:17974 ERROR TypeError: Cannot read property 'recalc' of undefined

I'm not doing anything special, just using smoovy as follows:

    this.scroller = nativeSmoothScroll(

      fromElement.nativeElement, {
        lerp: {
          damping: .1
        },
        native: {
          condition: () => window.innerWidth <= 768
        }
      }
    );

If you know what the issue might be and point me in the right direction, it would be great, otherwise I can try to make a stackblitz or open an MR :)

davideperozzi commented 4 years ago

Thank you for opening the issue! Should be fixed in version @smoovy/scroller@0.2.1 :)

davidstellini commented 4 years ago

Worked! Thanks :)