当前位置:网站首页>『快速入门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
前端成长日记
边栏推荐
- Window maximum and minimum settings
- 使用sed替换文件夹下文件
- 20220610其他:任务调度器
- 【C 题集】of Ⅵ
- Leetcode - 460 LFU cache (Design - hash table + bidirectional linked hash table + balanced binary tree (TreeSet))*
- LeetCode - 706 设计哈希映射(设计) *
- QT detection card reader analog keyboard input
- CV learning notes - BP neural network training example (including detailed calculation process and formula derivation)
- The data read by pandas is saved to the MySQL database
- LeetCode - 705 设计哈希集合(设计)
猜你喜欢
Swing transformer details-2
Swing transformer details-1
My notes on intelligent charging pile development (II): overview of system hardware circuit design
Mobile phones are a kind of MCU, but the hardware it uses is not 51 chip
CV learning notes alexnet
Opencv gray histogram, histogram specification
LeetCode - 1172 餐盘栈 (设计 - List + 小顶堆 + 栈))
CV learning notes - image filter
RESNET code details
openEuler kernel 技術分享 - 第1期 - kdump 基本原理、使用及案例介紹
随机推荐
LeetCode - 673. Number of longest increasing subsequences
Tensorflow built-in evaluation
LeetCode - 705 设计哈希集合(设计)
I think all friends should know that the basic law of learning is: from easy to difficult
Connect Alibaba cloud servers in the form of key pairs
My notes on the development of intelligent charging pile (III): overview of the overall design of the system software
STM32 general timer output PWM control steering gear
getopt_ Typical use of long function
RESNET code details
2.2 DP: Value Iteration & Gambler‘s Problem
4G module at command communication package interface designed by charging pile
Window maximum and minimum settings
Dynamic layout management
Development of intelligent charging pile (I): overview of the overall design of the system
Vgg16 migration learning source code
Markdown latex full quantifier and existential quantifier (for all, existential)
CV learning notes - clustering
Design of charging pile mqtt transplantation based on 4G EC20 module
Serial port programming
[combinatorics] Introduction to Combinatorics (combinatorial idea 3: upper and lower bound approximation | upper and lower bound approximation example Remsey number)