Q:

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?

A:

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); 

  } 

});

 

原文取自: http://stackoverflow.com/questions/5693082/gwt-browser-window-resized-handler 


arrow
arrow
    創作者介紹
    創作者 Frank 的頭像
    Frank

    經驗交流分享與備忘

    Frank 發表在 痞客邦 留言(0) 人氣()