当前位置:网站首页>『快速入门electron』之实现窗口拖拽
『快速入门electron』之实现窗口拖拽
2022-07-03 09:20:00 【InfoQ】
看完本文你可学会
- 对于进程通信有基本的一个了解
- 学会自定义的顶部栏如何实现拖拽功能
前情提要
实现拖拽功能
...
frame:false,
...
index.html
<div class="header"></div>
mousedown
mouseup
mousemove
let isDown = false; // 鼠标状态
let baseX = 0,baseY = 0; //监听坐标
mousedown
header.addEventListener('mousedown',function(e){
isDown = true
baseX = e.x
baseY = e.y
})


(screenX - baseX) , (screenY - baseY)
document.addEventListener('mousemove',function(e){
if(isDown){
const x = e.screenX - baseX
const y = e.screenY - baseY
ipcRenderer.send('move-application',{
posX:x,
posY:y
})
}
})
x,y
setPosition
ipcMain.on('move-application',(event,pos) => {
mainWin && mainWin.setPosition(pos.posX,pos.posY)
})

isDown
document.addEventListener('mouseup',function(){
isDown = false
})
Electron系列文
- 手把手带你快速入门Electron)
- 包包yyds:从 Electron 架构出发,深究 Electron 跨端原理 | 多图详解
- 小f的插件配上猪皮的文:vue + electron 开发一个实时监测github的跨端桌面应用
最后
Ned
前端成长日记
边栏推荐
- LeetCode - 919. 完全二叉树插入器 (数组)
- Swing transformer details-2
- Liquid crystal display
- Opencv Harris corner detection
- Mobile phones are a kind of MCU, but the hardware it uses is not 51 chip
- Leetcode-106:根据中后序遍历序列构造二叉树
- My notes on the development of intelligent charging pile (III): overview of the overall design of the system software
- 2.2 DP: Value Iteration & Gambler‘s Problem
- 4G module at command communication package interface designed by charging pile
- MySQL root user needs sudo login
猜你喜欢
4.1 Temporal Differential of one step
Vgg16 migration learning source code
Opencv notes 20 PCA
Installation and removal of MySQL under Windows
yocto 技术分享第四期:自定义增加软件包支持
LeetCode - 919. Full binary tree inserter (array)
MySQL root user needs sudo login
Leetcode - 933 number of recent requests
The new series of MCU also continues the two advantages of STM32 product family: low voltage and energy saving
Not many people can finally bring their interests to college graduation
随机推荐
Leetcode-100:相同的树
Development of intelligent charging pile (I): overview of the overall design of the system
Connect Alibaba cloud servers in the form of key pairs
yocto 技术分享第四期:自定义增加软件包支持
3.1 Monte Carlo Methods & case study: Blackjack of on-Policy Evaluation
Dynamic layout management
2312. Selling wood blocks | things about the interviewer and crazy Zhang San (leetcode, with mind map + all solutions)
Leetcode - 1670 conception de la file d'attente avant, moyenne et arrière (conception - deux files d'attente à double extrémité)
Simulate mouse click
4.1 Temporal Differential of one step
is_ power_ of_ 2 judge whether it is a multiple of 2
Window maximum and minimum settings
CV learning notes alexnet
yocto 技術分享第四期:自定義增加軟件包支持
Leetcode - 895 maximum frequency stack (Design - hash table + priority queue hash table + stack)*
El table X-axis direction (horizontal) scroll bar slides to the right by default
LeetCode - 895 最大频率栈(设计- 哈希表+优先队列 哈希表 + 栈) *
Tensorflow built-in evaluation
I think all friends should know that the basic law of learning is: from easy to difficult
Google browser plug-in recommendation