Have the option of making the sketchfield resize on other events than window resize
See original GitHub issueI 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:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Cool thx, hope you like the new feature/bug fix
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.