【发布时间】:2013-10-15 18:55:12
【问题描述】:
我创建了一个带有窗口的 Chrome 应用,但它不能移动。我想让顶部栏(HTML/CSS 样式)允许它移动。我查看了 Chrome 应用示例,但找不到使拖动窗口成为可能的代码。
【问题讨论】:
标签: google-chrome google-chrome-extension google-chrome-app
我创建了一个带有窗口的 Chrome 应用,但它不能移动。我想让顶部栏(HTML/CSS 样式)允许它移动。我查看了 Chrome 应用示例,但找不到使拖动窗口成为可能的代码。
【问题讨论】:
标签: google-chrome google-chrome-extension google-chrome-app
我发现了答案,但它没有出现在文档中,也不是很明显。它是一个控制它的 CSS 属性。
-webkit-app-region: drag;
否则,您的无框窗口将无法移动。
重要提示:您希望可点击或可交互的可拖动节点的任何子节点都需要其 CSS 上的 -webkit-app-region: no-drag;。
例如:
.myCustomBar {
position: absolute;
width: 100%;
height: 30px;
-webkit-app-region: drag;
}
.myCustomBarCloseButton {
position: relative;
width: 100px;
height: 30px;
-webkit-app-region: no-drag;
}
【讨论】:
Just add below code in your background.js
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create("frameless_window.html",
{ frame: "none",
id: "framelessWinID",
innerBounds: {
width: 360,
height: 300,
left: 600,
minWidth: 220,
minHeight: 220
}
}
);
})
And follow https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/frameless-window
Here you can find the best sample for creating frameless chrome app with the movable window.It's little bit confusing because, after installing it in chrome you can able to create its shortcut on the desktop as well.
【讨论】: