Orientation change event implementation by jquery mobile in phone gap

后端 未结 4 1091
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-31 18:52

Could someone please let me know the right code for orientation change event by jquery mobile in phone gap? Where and how do I implement this orientationChange function?

4条回答
  •  耶瑟儿~
    2021-01-31 19:11

    $(window).bind( 'orientationchange', function(e){
        if ($.event.special.orientationchange.orientation() == "portrait") {
            //Do whatever in portrait mode
        } else {
            //Do Whatever in landscape mode
        }
    });
    

    You can add the resize event in the event parameter of the bind function, if you're targeting iOS and orientationchange doesn't work. Since changing orientation fires the resize event too.

提交回复
热议问题