AshesOfOwls / jquery.shapeshift

A dynamic grid system with drag and drop functionality.
http://ashesofowls.github.com/jquery.shapeshift/
MIT License
1.67k stars 311 forks source link

ipad orientation change issue #96

Open JeganGitHub opened 10 years ago

JeganGitHub commented 10 years ago

First I thank for this cool plugin that's exactly what I was looking for. It works perfectly on desktop and works fine when you resize the window without any flaws, but when I use the iPad it does not re-arrange it if I switch from portrait to landscape. It actually works fine if I start with landscape to begin with and go back and forth works, but the other way around it doesn't. I tried triggering the ss-rearrange in both window resize and orientationchange events and that didn't fix this issue. Any help is appreciated. Thanks.

maryisdead commented 9 years ago

Can confirm. The failing code looks somewhat like that:

window.onorientationchange = function()
{
    var
        widget_width = 280,
        window_width = window.innerWidth;

    if (window_width < 1200 && window_width >= 992)
    {
        widget_width = 220;
    }
    else if (window_width < 992 && window_width > 768)
    {
        widget_width = 220;
    }
    else if (window_width <= 768)
    {
        widget_width = 280;
    }

    myShapeshifterOptions =
    {
        selector: '.DashboardItem',
        handle: '.Widget-header',
        gutterX: 20,
        gutterY: 20,
        paddingX: 0,
        paddingY: 0,
        align: "left",
        enableDrag: false,
        animated: true,
        colWidth: widget_width
    };

    // Doesn't work
    myShapeshift.trigger('ss-destroy');
    myShapeshift.shapeshift(myShapeshifterOptions);
    myShapeshift.trigger("ss-rearrange");

    // Works, but ugly
    setTimeout(function()
    {
        myShapeshift.trigger('ss-destroy');
        myShapeshift.shapeshift(myShapeshifterOptions);
        myShapeshift.trigger("ss-rearrange");
    }, 1000);
};

It seems like Shapeshift is somehow late to the party when recalculating stuff. We've been banging our heads against this for a day now and can't really pinpoint what the real issue is.