Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windowResized() not firing #308

Closed
stephanbogner opened this issue Jan 13, 2024 · 4 comments
Closed

windowResized() not firing #308

stephanbogner opened this issue Jan 13, 2024 · 4 comments
Assignees
Labels

Comments

@stephanbogner
Copy link

Expected Behavior

p5.windowResized = () => {} should be triggered when the window is resized

Actual Behavior

Doesn't fire. Should it be supported or is this by design/limitation?

Steps to Reproduce the Problem

Note: I am using NextJS but I assume this is not an issue specific to @p5-wrapper/next

import * as React from "react"
import { NextReactP5Wrapper } from "@p5-wrapper/next"

function sketch(p5) {
    p5.setup = () => p5.createCanvas(600, 400, p5.WEBGL)

    p5.draw = () => {
        p5.background(250)
        p5.normalMaterial()
        p5.push()
        p5.rotateZ(p5.frameCount * 0.01)
        p5.rotateX(p5.frameCount * 0.01)
        p5.rotateY(p5.frameCount * 0.01)
        p5.plane(100)
        p5.pop()
    }

    p5.windowResized = () => {
        console.log('resized')
    }
}

export default function({ width, height }) {
  return <NextReactP5Wrapper sketch={sketch} />
}

Specifications

On Mac using Brave
"@p5-wrapper/next": "^0.2.0"
"@p5-wrapper/react": "^4.2.0"

@stephanbogner
Copy link
Author

For now I am using the workaround document.addEventListener('resize', p5.windowResized) inside p5.setup

@jamesrweb
Copy link
Collaborator

jamesrweb commented Jan 14, 2024

There's no limitation on p5 in this package. This package simply wraps the p5 value constructed via instance mode.

You should check upstream if you can't see the function being correctly exposed. If it is correctly exposed and you say that your "workaround" works though, I would assume it's a next issue OR that the instance mode event handler works differently when compared with global mode.

@jamesrweb jamesrweb self-assigned this Jan 22, 2024
@jamesrweb
Copy link
Collaborator

Closing issue due to inactivity and reasons outlined above.

@jamesrweb jamesrweb closed this as not planned Won't fix, can't repro, duplicate, stale Jan 22, 2024
@stephanbogner
Copy link
Author

stephanbogner commented Jan 22, 2024

@jamesrweb Sorry, I didn't have time yet to check if it works without Nextjs. Thanks for clarifying and explaining 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants