From ba53da72d4c8e1c1f21ac27c86c16a3f6a75c6d6 Mon Sep 17 00:00:00 2001 From: Anthony Tseng Date: Sat, 17 Sep 2016 22:41:30 +0800 Subject: [PATCH] 1. Make swipe distance shorter 2. Use scroll-touch-edge to solve swipe conflict requires brave/electron#58 fix #2548, #4064 Auditors: @bbondy Test Plan: for swipe conflict 1. Go to https://hootsuite.com 2. Create timelines as much as you have to scroll horizontally --- js/components/main.js | 11 ++++++++--- js/stores/appStore.js | 4 ++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/js/components/main.js b/js/components/main.js index c85429ebe52..9d146f136e8 100644 --- a/js/components/main.js +++ b/js/components/main.js @@ -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 @@ -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) } } @@ -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)) } diff --git a/js/stores/appStore.js b/js/stores/appStore.js index 3a9fd395b0e..96495ea52ec 100644 --- a/js/stores/appStore.js +++ b/js/stores/appStore.js @@ -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)