Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #4083 from darkdh/swipe
Browse files Browse the repository at this point in the history
Swipe behavior fix
  • Loading branch information
bbondy authored Sep 18, 2016
2 parents 49b07d1 + ba53da7 commit 5330ee7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 8 additions & 3 deletions js/components/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class Main extends ImmutableComponent {
var swipeGesture = false
var canSwipeBack = false
var canSwipeForward = false
var isSwipeOnEdge = false
var deltaX = 0
var deltaY = 0
var startTime = 0
Expand Down Expand Up @@ -192,14 +193,15 @@ class Main extends ImmutableComponent {
if (swipeGesture &&
systemPreferences.isSwipeTrackingFromScrollEventsEnabled()) {
trackingFingers = true
isSwipeOnEdge = false
startTime = (new Date()).getTime()
}
})
ipc.on('scroll-touch-end', function () {
if (time > 50 && trackingFingers && Math.abs(deltaY) < 50) {
if (deltaX > 100 && canSwipeForward) {
if (time > 50 && trackingFingers && Math.abs(deltaY) < 50 && isSwipeOnEdge) {
if (deltaX > 70 && canSwipeForward) {
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_FORWARD)
} else if (deltaX < -100 && canSwipeBack) {
} else if (deltaX < -70 && canSwipeBack) {
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_BACK)
}
}
Expand All @@ -210,6 +212,9 @@ class Main extends ImmutableComponent {
deltaY = 0
startTime = 0
})
ipc.on('scroll-touch-edge', function () {
isSwipeOnEdge = true
})
ipc.on(messages.LEAVE_FULL_SCREEN, this.exitFullScreen.bind(this))
}

Expand Down
4 changes: 4 additions & 0 deletions js/stores/appStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ const createWindow = (browserOpts, defaults, frameOpts, windowState) => {
mainWindow.webContents.send('scroll-touch-end')
})

mainWindow.on('scroll-touch-edge', function (e) {
mainWindow.webContents.send('scroll-touch-edge')
})

mainWindow.on('enter-full-screen', function () {
if (mainWindow.isMenuBarVisible()) {
mainWindow.setMenuBarVisibility(false)
Expand Down

0 comments on commit 5330ee7

Please sign in to comment.