I am developing a GWT application that render a text on a canvas. I want to resize the canvas whenever browser window resized. The problem is if I used Window.addResizeHandler, the rendering process with each resize will be very slow. So I need a way to resize the canvas only when the user release the mouse button after finishing resize. Is there anyway to do that?
You could add a delay, so that the resize is only processed after the window hasn't been resized for some number of milliseconds:
Window.addResizeHandler(new ResizeHandler() {
Timer resizeTimer = new Timer() {
@Override
public void run() {
doComplexLayoutCalculations();
}
};
@Override
public void onResize(ResizeEvent event) {
resizeTimer.cancel();
resizeTimer.schedule(250);
}
});
Window.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
Scheduler.get().scheduleDeferred(
new Scheduler.ScheduledCommand() {
public void execute() {
// layout stuff
}
});
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With