Skip to content

Laying out Enhanced Elements

thepian edited this page Sep 27, 2012 · 9 revisions

Resize callback

When the page is resized or adjacent elements will be notified with the new dimensions.

You should throttle the layout handler so resizing will only be done so often. When resizing the browser updates are sent of every pixel change to give the smoothest user experience. Throttling gives you a balance between visual feedback and overall system performance.

PresentationLoader.layout_presentation = function(el,layout,instance) 
{
    if (typeof instance != "object") return;
    
    if (layout.displayed == false) {
        if (layout.oldDisplayed == true) instance.onHide();
        layout.oldDisplayed = layout.displayed;
    } else {
        if (layout.oldDisplayed == false) instance.onShow();
        layout.oldDisplayed = layout.displayed;
        
        instance.onResize(el.offsetWidth,el.offsetHeight);
    }
};
PresentationLoader.layout_presentation.throttle = 250;

By adding a throttle property to the layout handler function calls will not come until the time in milliseconds have elapsed after the previous call.

Clone this wiki locally