Git Product home page Git Product logo

Comments (3)

jamesrweb avatar jamesrweb commented on April 27, 2024

I can't reproduce this locally. The only thing I can think of is that the viewport is somehow not maintaining the aspect ratio for some reason.

Can you show me the css-box-model for the canvas, canvas wrapper div and your own div?

from react.

jamesrweb avatar jamesrweb commented on April 27, 2024

Closing due to inactivity.

from react.

mnvr avatar mnvr commented on April 27, 2024

I also ran into the same issue.

  • I started with a p5.createCanvas 300x300 px, and the div that contained the Sketch was also set to height 300px.
  • However, the ReactP5Wrapper component ended up with a height of 304px.
  • I tried looking around in the CSS, but I couldn't spot anything that might be causing it either in my own code, nor in react-p5. That said, I might not have looked at the right places.
  • I'm on macOS 14.0. I'm using Gatsby with styled components. I was testing on Chrome, but I also saw the same behaviour on Safari when I checked.

I also found a workaround - setting display: flex on the container of ReactP5Wrapper made the extra pixels go away (You can see an example here - https://github.com/mnvr/mrmr.io/blob/main/pages/ai-religion/components.tsx#L59-L64).


Anyways, I'm not actually sure if this is a library issue or something else that's wrong, but I just thought I'll mention that I also faced this, and also mention the display: flex a hack to workaround the issue.

ps. Thanks for the great library, it's a pleasure to use this!

from react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.