简体   繁体   English

科尔多瓦方向改变

[英]Cordova orientation change

Good day brave cordova developers! 美好的一天,勇敢的cordova开发人员! The main question is how to detect that corientation change is ended and window is redrawn? 主要问题是如何检测方向改变已结束并重新绘制窗口?

I used 250ms time delay, but i'm afraid that on some slower devices this woud be not anough. 我使用了250ms的时间延迟,但恐怕在某些较慢的设备上,这还不够好。

var app = {

    initialize: function() {
        this.bindEvents();
    },
    bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
    },
    onDeviceReady: function() {
      init_video();
      window.addEventListener('orientationchange', init_video);
    },
};

var init_video = function(){
    //insert time out to let window to redraw
    setTimeout(function() {
        console.log('oriantation:'+window.orientation+'\nwidth: ' + window.outerWidth + '\nheight: '+ window.outerHeight);
    }, 250);
}

你可以在CSS与像媒体查询chceck这在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM