when i resize the window,context be cleared?
kkxlkkxllb opened this issue · 6 comments
when i resize the browser window, why the canvas context be cleared?
Hi. Thanks for trying Sketch!
There's a flag called autoclear
(which defaults to true
), so if you construct the Sketch like below the canvas won't be cleared automatically (see the wiki for more info)
Sketch.create({
autoclear: false,
setup: ...
draw: ...
});
i found the real reason, eventMap's resize was in conflict with window resize event, so when i resize the browser window, it trigger sketch.js resize always.
Yep, that's the expected behavior when you have fullscreen
set to true since it needs to always fit the window. Resizing a canvas will aways clear the pixels and reset the state. If you don't want this to happen, you'll need to set fullscreen
to false
, specify a width and height and resize yourself manually.
Sketch.create({
autoclear: false,
fullscreen: false,
width: 800,
height: 600,
...
});
I have set fullscreen
to true and also height & width, but it just clear the canvas when i resize browser window.
I test it on your "drawing" example both chrome and safari. same behavior.
Sketch.create({
fullscreen: false,
height: 600,
width: 600,
container: document.getElementById( 'container' ),
autoclear: false,
...
});
You're right, I see what you mean now. The latest commit should have fixed it (here's an example.)
Thanks for spotting this!
Great work, thanks!