Kinrany/vue-p5

`windowResized` may not be called as expected

agm1984 opened this issue · 3 comments

Hey I'm having an issue with the windowResized event.

        <vue-p5
            :additionalEvents="['windowResized']"
            @setup="setup"
            @draw="draw"
            @windowResized="windowResized"
        ></vue-p5>

These don't work for me. I found this issue thread: #11

In here, you recommended:

            document.addEventListener('resize', () => {
                sketch.resizeCanvas(window.innerWidth, window.innerHeight);
            });

That also doesn't work for me, and the issue is that document.addEventListener() doesn't work. When I change it to window, it starts working and correctly fires the resize event.

I figured I would make an issue for this in case anyone else encounters this. It will probably affect the generic/edge cases around :additionalEvents="[]" if it is calling document. in the library code.

Beyond that, nice work. I just ported over an ancient vanilla JavaScript "sacred geometry" generator, and the code is so much nicer to work with now via vue-p5.

Hi, thanks for the kind words!

Please try lowercase @windowresized instead of @windowResized. Also it's already supported, so you don't need :additionalEvents!

This is a gotcha multiple people have already had issues with, so I guess it's finally time for me to add FAQ :D

Thanks for the turbo reply velocity. I just tried and that did work. Thanks a lot.

You're welcome 🙂