Code Monkey home page Code Monkey logo

Comments (5)

desandro avatar desandro commented on May 18, 2024

If you'd like to see more resize options, please add a 👍 and respond with which behavior from above you're looking for.


Hi Jack. Thanks for digging into this and for your careful consideration of the issue.

Currently resize: true works as resize: 'respect-natural-dom-size-and-css' (as you put it). Zdog takes the original width and height measurements, and then updates the rendering element & internal geometries to match that display ratio. If you inspect the canvas demo, you'll see the actual width and height attributes change. In the SVG demo, the viewBox attribute changess. With resize: true canvas and SVG element both with scale proportionally, but the outer CSS may differ between the two elements.

As for the other use cases, yeah, I can see people needing these. But I'd like to hear what they're trying to achieve before I start more features. Dealing with resizing was tricky.

from zdog.

jackrugile avatar jackrugile commented on May 18, 2024

Thanks for your reply. Yeah, resizing is definitely a tricky thing. Expectations from developers could vary widely.

I think I may not be seeing the same thing as you described. In test case 1, the canvas does not change size for me when resizing my browser. It stays at 480px × 280px. I'm attaching a GIF of the behavior I see here just to clarify. Do you get the same behavior?

resize

With your description, I would expect to see the canvas element expand to the full width of the browser while retaining a 2:1 aspect ratio since it has the following CSS:

.zdog-canvas {
  display: block;
  width: 100%;
}

I wonder if this might be an issue where the browser needs an extra frame to recalculate the DOM's representation? Kind of like how if you remove a CSS class and then add the CSS class back to the same element within the same frame of execution, you wouldn't see any change.

from zdog.

desandro avatar desandro commented on May 18, 2024

Aaaaaah. There's a bug with high pixelRatio screens. Dang. Okay, I'll look into this. Thanks for reporting that.

from zdog.

jackrugile avatar jackrugile commented on May 18, 2024

Oh ok, great to hear! I think fixing that should solve everything that was going through my head. There's no need to add extra complications since resize: true as you described is super flexible. All of the above scenarios I outlined could be covered with that.

Feel free to close this once fixed, thanks!

from zdog.

desandro avatar desandro commented on May 18, 2024

v1.0.2 has been released with fix for this bug Please update! Thanks again for reporting this issue. Closing as fixed.

from zdog.

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.