Wednesday, September 24, 2008

Tip: Improve resizing performance

Posted by Benjamin Schirmer, Google Desktop Intern

If your gadget has lots of visual elements, resizing might get very slow. This happens because onsize is triggered often when the user resizes your gadget. Use code like this to improve the performance of resizing:
 var resizeTimeout = null;

function view_onSize() {
resizeTimeout = setTimeout(resizeGadget, 10);

function resizeGadget() {'Now I really resize everything');
... code to resize and relayout the gadget's contents ...
The resizeGadget() function is called only when the user is either finished with resizing or doesn't resize for a few milliseconds. The result is fewer redraws of your gadget and a smoother resizing experience for your user.

Have a tip you'd like to share? Send it to gd-developer AT google DOT com. To see all tips, choose the Tips label.

Link - from Google Desktop APIs Blog

No comments: