Grow your CSS skills. Land your dream job.

reload jquery functions on ipad orientation change

  • # February 15, 2012 at 7:16 am

    Hey All

    I have found that usually matchmedia.js works pretty well running specific jquery for specific screen sizes..however I running into a little problem with a carousel not resizing correctly on ipad orientation change, i’ve been on this for a day now and I’m slowly losing my mind

    I’ve looked at binding the window resize event to reload the page…and this works but is not ideal…is anyone aware of a technique or plugin to reload specific jquery functions on orientation or window resize?

    cheers

    # February 15, 2012 at 10:16 am

    I normally put all the stuff that needs doing on a resize or reload in one function and then bind and call that function at load, resize and orient. You can always split. It up into separate resize and orient functions and call both at load but only one at resize etc.



    function myOrientResizeFunction(){
    all resize/orientation stuff to do in here
    }

    //bind to resize
    $(window).resize( function() {
    myOrientResizeFunction()
    });


    //if you need to call it at page load to resize elements etc.
    $(window).load( function() {
    myOrientResizeFunction()
    });

    //check for the orientation event and bind accordingly
    if (window.DeviceOrientationEvent) {
    window.addEventListener('orientationchange', myOrientResizeFunction, false);
    }
    # February 16, 2012 at 1:58 pm

    thanks

    I was obviously going about it the wrong way…but I seem to be getting there now

    thanks

    # June 27, 2013 at 3:20 am

    thanks

    bungle

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".