Skip to content

Instantly share code, notes, and snippets.

@Imperat
Created March 26, 2024 05:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Imperat/89a9e0f55b98b47eeb77445ff886bd4b to your computer and use it in GitHub Desktop.
Save Imperat/89a9e0f55b98b47eeb77445ff886bd4b to your computer and use it in GitHub Desktop.
Reproduce bug with Electron webkit-app-region: drag
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'">
<link href="./styles.css" rel="stylesheet">
<title>Hello World!</title>
</head>
<body>
<div class="items-list" id="itemsList">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<script src="./index.js"></script>
</body>
</html>
const itemsList = document.getElementById('itemsList');
itemsList.addEventListener('mouseleave', () => {
console.log('on mouse leave fired');
});
const { app, BrowserView, BrowserWindow } = require('electron')
function createWindow () {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
titleBarStyle: 'hidden',
});
const browserView = new BrowserView();
mainWindow.addBrowserView(browserView);
browserView.setBounds({ x: 0, y: 0, width: 800, height: 200 });
browserView.setAutoResize({ width: true });
browserView.webContents.loadFile('index.html');
browserView.webContents.openDevTools();
}
app.whenReady().then(createWindow);
{
"name": "lamentable-gene-rise-8rgoa",
"productName": "lamentable-gene-rise-8rgoa",
"description": "My Electron application description",
"keywords": [],
"main": "./main.js",
"version": "1.0.0",
"author": "leliakin",
"scripts": {
"start": "electron ."
},
"dependencies": {},
"devDependencies": {
"electron": "27.3.2"
}
}
body {
margin: 0;
}
.items-list {
margin-left: 100px;
max-width: 100%;
border: 1px solid orange;
display: flex;
flex-shrink: 1;
-webkit-app-region: drag;
}
.item {
padding: 10px;
width: 50px;
background: blue;
-webkit-app-region: no-drag;
}
.item:hover {
background: yellow;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment