Mobile viewport height after orientation change

后端 未结 10 1414
孤街浪徒
孤街浪徒 2020-12-03 04:30

I am attaching a listener to the orientationchange event:

window.addEventListener(\'orientationchange\', function () {
    console.log(window.innerHeight);
}         


        
10条回答
  •  既然无缘
    2020-12-03 05:19

    Orientation change needs a delay to pick up on the new heights and widths. This works 80% of the time.

    window.setTimeout(function() {
        //insert logic with height or width calulations here.
    }, 200);
    

提交回复
热议问题