Kinrany / vue-p5

Vue component for p5.js
125 stars 16 forks source link

Missing 'windowResized' event #11

Closed prnxdev closed 4 years ago

prnxdev commented 5 years ago

When I defined windowResized method it doesn't work. I can't make responsive canvas.

Kinrany commented 5 years ago

Thanks for the report!

I'll update the package soon™, but in the meantime you might be able to achieve the same effect using document.addEventListener. Something like this should work:

new Vue({
  el: '#app',
  methods: {
    setup(sketch) {
      sketch.background('green');
      sketch.text('Hello p5!', 20, 20);

      document.addEventListener('resize', () => {
        sketch.resizeCanvas(window.innerWidth, window.innerHeight);
      });
    }
  }
});
prnxdev commented 5 years ago

Dope. Thanks :)

Kinrany commented 5 years ago

I'll keep this issue open until I get around to actually fixing it :)

Kinrany commented 5 years ago

Just released vue-p5@0.8.0-rc1. It supports windowResized and also allows registering new events in case there are others I missed.