es/Algorithm.js
// move float panel into the screen
move float panel into the screen
move float panel into the screen
function fixFloatPanelPos(layout, layoutWidth, layoutHeight) {
    let layoutChanged = false;
    if (layout && layout.floatbox && layoutWidth > 200 && layoutHeight > 200) {
        let newFloatChildren = layout.floatbox.children.concat();
        for (let i = 0; i < newFloatChildren.length; ++i) {
            let panel = newFloatChildren[i];
            let panelChange = {};
            if (panel.w > layoutWidth) {
                panelChange.w = layoutWidth;
            }
            if (panel.h > layoutHeight) {
                panelChange.h = layoutHeight;
            }
            if (panel.y > layoutHeight - 16) {
                panelChange.y = Math.max(layoutHeight - 16 - (panel.h >> 1), 0);
            }
            else if (panel.y < 0) {
                panelChange.y = 0;
            }
            if (panel.x + panel.w < 16) {
                panelChange.x = 16 - (panel.w >> 1);
            }
            else if (panel.x > layoutWidth - 16) {
                panelChange.x = layoutWidth - 16 - (panel.w >> 1);
            }
            if (Object.keys(panelChange).length) {
                newFloatChildren[i] = clone(panel, panelChange);
                layoutChanged = true;
            }
        }
        if (layoutChanged) {
            let newBox = clone(layout.floatbox);
            newBox.children = newFloatChildren;
            return replaceBox(layout, layout.floatbox, newBox);
        }
    }
    return layout;
}
function fixFloatPanelPos ( layout , layoutWidth , layoutHeight ) { let layoutChanged = false ; if ( layout && layout . floatbox && layoutWidth > 200 && layoutHeight > 200 ) { let newFloatChildren = layout . floatbox . children . concat ( ) ; for ( let i = 0 ; i < newFloatChildren . length ; ++ i ) { let panel = newFloatChildren [ i ] ; let panelChange = { } ; if ( panel . w > layoutWidth ) { panelChange . w = layoutWidth ; } if ( panel . h > layoutHeight ) { panelChange . h = layoutHeight ; } if ( panel . y > layoutHeight - 16 ) { panelChange . y = Math . max ( layoutHeight - 16 - ( panel . h >> 1 ) , 0 ) ; } else if ( panel . y < 0 ) { panelChange . y = 0 ; } if ( panel . x + panel . w < 16 ) { panelChange . x = 16 - ( panel . w >> 1 ) ; } else if ( panel . x > layoutWidth - 16 ) { panelChange . x = layoutWidth - 16 - ( panel . w >> 1 ) ; } if ( Object . keys ( panelChange ) . length ) { newFloatChildren [ i ] = clone ( panel , panelChange ) ; layoutChanged = true ; } } if ( layoutChanged ) { let newBox = clone ( layout . floatbox ) ; newBox . children = newFloatChildren ; return replaceBox ( layout , layout . floatbox , newBox ) ; } } return layout ; }
move float panel into the screen
move float panel into the screen