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

Commit

Permalink
Using scroll-touch-edge to record the distance cause wheel event will
Browse files Browse the repository at this point in the history
only fire once each scroll since C69

mainly
fix #15114

also
fix #14871
fix #14829
fix #14785

Auditor: @bsclifton
  • Loading branch information
darkdh committed Aug 30, 2018
1 parent 8e09743 commit c46f54c
Showing 1 changed file with 19 additions and 30 deletions.
49 changes: 19 additions & 30 deletions app/renderer/components/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,6 @@ class Main extends React.Component {
// Navigates back/forward on macOS two- and or three-finger swipe
let trackingFingers = false
let startTime = 0
let isSwipeOnLeftEdge = false
let isSwipeOnRightEdge = false
let deltaX = 0
let deltaY = 0
let time
Expand All @@ -235,22 +233,6 @@ class Main extends React.Component {
if (trackingFingers) {
deltaX = deltaX + e.deltaX
deltaY = deltaY + e.deltaY
const distanceThresholdX = getSetting(settings.SWIPE_NAV_DISTANCE)
const percent = Math.abs(deltaX) / distanceThresholdX
if (isSwipeOnRightEdge) {
if (percent > 1) {
appActions.swipedRight(1)
} else {
appActions.swipedRight(percent)
}
} else if (isSwipeOnLeftEdge) {
if (percent > 1) {
appActions.swipedLeft(1)
} else {
appActions.swipedLeft(percent)
}
}
time = (new Date()).getTime() - startTime
}
}, { passive: true })

Expand All @@ -259,9 +241,9 @@ class Main extends React.Component {
const distanceThresholdY = 101
const timeThreshold = 80
if (trackingFingers && time > timeThreshold && Math.abs(deltaY) < distanceThresholdY) {
if (deltaX > distanceThresholdX && isSwipeOnRightEdge) {
if (deltaX > distanceThresholdX) {
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_FORWARD)
} else if (deltaX < -distanceThresholdX && isSwipeOnLeftEdge) {
} else if (deltaX < -distanceThresholdX) {
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_BACK)
}
}
Expand All @@ -275,16 +257,23 @@ class Main extends React.Component {

ipc.on('scroll-touch-edge', () => {
if (trackingFingers) {
if (!isSwipeOnRightEdge && deltaX > 0) {
isSwipeOnRightEdge = true
isSwipeOnLeftEdge = false
time = 0
deltaX = 0
} else if (!isSwipeOnLeftEdge && deltaX < 0) {
isSwipeOnLeftEdge = true
isSwipeOnRightEdge = false
time = 0
deltaX = 0
const distanceThresholdX = getSetting(settings.SWIPE_NAV_DISTANCE)
const percent = Math.abs(deltaX) / distanceThresholdX
time = (new Date()).getTime() - startTime
if (deltaX > 0) {
if (percent > 1) {
appActions.swipedRight(1)
} else {
appActions.swipedRight(percent)
}
deltaX += 1
} else if (deltaX < 0) {
if (percent > 1) {
appActions.swipedLeft(1)
} else {
appActions.swipedLeft(percent)
}
deltaX -= 1
}
}
})
Expand Down

0 comments on commit c46f54c

Please sign in to comment.