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.

Have the option of making the sketchfield resize on other events than window resize

See original GitHub issue

I wanted to have a resizable sketch field but when I resize it (change height and width props of SketchField) the canvas stays the same size. To make it work I had to manually trigger the resize event of window. Like this:

    componentDidUpdate: function () {
        var sketch = this.refs.sketch;
        var style = this.props.style;
        if (style.width !== sketch._canvas.clientWidth || style.height !== sketch._canvas.clientHeight) {
            window.dispatchEvent(new Event("resize"));
        }
    },

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tboliscommented, Sep 29, 2016

Cool thx, hope you like the new feature/bug fix

1reaction
tboliscommented, Sep 29, 2016

Dear @FerusAndBeyond thank you for your input, I have resolved the issue by adding controlled properties width and height, please check if possible and let me know if it is ok, you can see the example page as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Window: resize event - Web APIs | MDN
The resize event fires when the document view (window) has been resized. This event is not cancelable and does not bubble.
Read more >
Re-render a React Component on Window Resize | Pluralsight
React doesn't have a resize event baked into it, but we can listen to the native browser window resize event from within our...
Read more >
JavaScript window resize event - Stack Overflow
Best practice is to add to the resize event, rather than replace it: window.addEventListener('resize', function(event) { ... }, true);.
Read more >
ResizeObserver: it's like document.onresize for elements
ResizeObserver notifies you when an element's content rectangle changes size so that you can react accordingly.
Read more >
How to wait resize end event and then perform an action using ...
When we resize the browser window, the “resize” event is fired continuously, multiple times while resizing. We want the “resize” event to ...
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