Javascript KineticJS android舞台尺寸

Javascript KineticJS android舞台尺寸,javascript,android,height,width,kineticjs,Javascript,Android,Height,Width,Kineticjs,定义KineticJS阶段我会这样做: var stage = new Kinetic.Stage({ container: 'container', width: 320, height: 480 }); 所以舞台的宽度和高度是固定的。 如果分辨率不同,如何将其拉伸以适合手机屏幕?好吧,这确实是一个javascript问题。您希望使舞台的大小与窗口的大小相同。这对我的android项目很有用: var stage = new Kinetic.Stage({

定义KineticJS阶段我会这样做:

  var stage = new Kinetic.Stage({
    container: 'container',
    width: 320,
    height: 480
  });
所以舞台的宽度和高度是固定的。
如果分辨率不同,如何将其拉伸以适合手机屏幕?

好吧,这确实是一个javascript问题。您希望使舞台的大小与窗口的大小相同。这对我的android项目很有用:

 var stage = new Kinetic.Stage({
      container: 'container',
      width: window.innerWidth,
      height: window.innerHeight
 });
编辑:
此外,我建议您也添加jQuery,以便检查方向更改,然后您可以执行以下操作:

window.onresize = function(event) {  //this function will resize your stage to the size of your window
    stage.setWidth(window.innerWidth);
    stage.setHeight(window.innerHeight);
    stage.draw(); //redraw the stage, not sure if really needed, but good to have.
}
或者你可以:

window.onresize = function(event) {
    stage.setScale(x,y); //set x, y scale values when the orientation changes
    stage.draw(); //redraw the stage, not sure if really needed, but good to have.
}

KineticJS关心缩放触摸事件吗?缩放对我来说很好。在这里,看一看这个例子,你会发现你仍然可以正确拖动,无论比例如何。适用于touch和Desktop谢谢这对我帮助很大!但我有另一个问题:它的规模完美现在,但当我触摸屏它闪烁透明的蓝色整个div标签。这是一个浏览器主题,而不是kineticJS,因此我将向您介绍以下内容:这三个主题中的一个应该可以帮助您解决问题。