File size: 608 Bytes
0936134 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | const electron = require('electron')
const EventEmitter = require('events')
const { remote } = electron
class SwipeRightBehavior extends EventEmitter {
constructor () {
super()
this.mainWindow = remote.getCurrentWindow()
this.xLeader = this.mainWindow.getPosition()[0]
this.xFollower = this.xLeader
this.mainWindow.on('move', this.move.bind(this))
}
move () {
this.xFollower = this.xLeader
this.xLeader = this.mainWindow.getPosition()[0]
if (this.xFollower < this.xLeader) {
this.emit('behavior', 'swipedRight')
}
}
}
module.exports = SwipeRightBehavior
|