question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Canvas height shrinks as width shrinks (~ *0.5) (Scale ratio?)

See original GitHub issue

Expected Behavior Canvas would responsively resize to fit window.

Actual Behavior Height shrinks to half of canvas width during resize. W:H scaling ratio appears to be set to 2:1.

Specifications Version: 2.1.0 Browsers: Firefox 57, Chrome 62 package.json:

"dependencies": { "canvas-particle-network": "^1.5.0", "material-ui": "^1.0.0-beta.21", "material-ui-icons": "^1.0.0-beta.17", "material-ui-search-bar": "^1.0.0-beta.3", "react": "^16.1.1", "react-dom": "^16.1.1", "react-particles-js": "^2.1.0", "react-scripts": "1.0.17", "react-tap-event-plugin": "^3.0.2" }

Possible Solution: Stackoverflow

The solution is likely relatively simple. I however don’t understand how preventing the 2:1 scale ratio is implemented in the React component. Upon resolving I can add a note to the Readme.md

Edit: formatting

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
bichenkkcommented, Jan 27, 2018

@afparsons @EthanC you need to add style in the Particles

style={{
              position: "fixed",
              top: 0,
              left: 0,
              width: "100%",
              height: "100%"
          }}
1reaction
wufecommented, Apr 22, 2018

@begonaalvarezd You can use

style={{
    position: 'absolute',
    left: 0,
    right: 0,
    bottom: 0,
    top: 0
}}

Try this:

Edit l909x87lr7

Read more comments on GitHub >

github_iconTop Results From Across the Web

Canvas height shrinks as width shrinks (~ *0.5) (Scale ratio?)
Actual Behavior Height shrinks to half of canvas width during resize. W:H scaling ratio appears to be set to 2:1. Specifications Version: 2.1.0...
Read more >
javascript - Resize HTML5 canvas to fit window - Stack Overflow
For example, I can get a <div> to scale by setting the height and width properties to 100%, but a <canvas> won't scale,...
Read more >
Canvas Scaler, Explained | Unity Tutorial - YouTube
The Canvas Scaler comes by default whenever you make a Canvas in Unity, ... Scale With Screen Size - Shrink 09:20 Constant Physical...
Read more >
aspect-ratio - CSS-Tricks
In other words, this property helps us to size elements consistently, so the ratio of an element stays the same as it grows...
Read more >
Project frame size in Motion - Apple Support
In Motion, changing the size of the canvas does not change the size or ... This can result in objects being cut off...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found