Chrome app window cannot be moved partially outside of screen using moveTo

不打扰是莪最后的温柔 提交于 2019-12-06 00:15:54

Try using setBounds() instead of moveTo(), that works for me:

chrome.app.runtime.onLaunched.addListener(function() {
  chrome.app.window.create('window.html', {
    'bounds': {
      'width': 400,
      'height': 500
    }
  }, function(appwindow) {
     appwindow.setBounds({left: -200, top: 200, width: 400, height: 500});
  });
});

You don't even need to pass the width and height back:

appwindow.setBounds({ left: -200, top: 200 });

And to get the AppWindow object outside of the create() callback, use:

var appwindow = chrome.app.window.current();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!