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

Commit

Permalink
Supersede cd3dd78 by "scroll-touch-edge"
Browse files Browse the repository at this point in the history
Auditors: @bbondy

Test Plan:
1. Open google search result
2. Click any link and back to the search result
3. Make the window smaller by open dev console (shift + f8)
4. Make sure you can horizontally scroll the page
5. Make sure you can swipe back/forward when you scroll to the edge
  • Loading branch information
darkdh committed Sep 29, 2016
1 parent 74790fc commit a21be2b
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 58 deletions.
14 changes: 0 additions & 14 deletions app/extensions/brave/content/scripts/inputHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,3 @@ document.addEventListener('keydown', (e /*: Event*/) => {
break
}
})

chrome.ipc.on('check-swipe-back', (e) => {
if (document.scrollingElement.scrollLeft === 0) {
chrome.ipc.sendToHost('can-swipe-back')
}
})

chrome.ipc.on('check-swipe-forward', (e) => {
const scrollEle = document.scrollingElement
if (scrollEle.scrollLeft === 0 ||
scrollEle.scrollLeft === (scrollEle.scrollWidth - scrollEle.clientWidth)) {
chrome.ipc.sendToHost('can-swipe-forward')
}
})
17 changes: 0 additions & 17 deletions js/actions/webviewActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

'use strict'

const messages = require('../constants/messages.js')

const getWebview = () =>
document.querySelector('.frameWrapper.isActive webview')

Expand Down Expand Up @@ -53,21 +51,6 @@ const webviewActions = {
}
},

/**
* Check two-finger gesture swipe back/forward ability
* @param {bool} back - true for back, false for forward
*/
checkSwipe: function (back) {
const webview = getWebview()
if (webview) {
if (back) {
webview.send(messages.CHECK_SWIPE_BACK)
} else {
webview.send(messages.CHECK_SWIPE_FORWARD)
}
}
},

/**
* Set/unset webkit fullscreen status
* @param {Boolean} isFullScreen - fullscreen state to go to
Expand Down
6 changes: 0 additions & 6 deletions js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -753,12 +753,6 @@ class Frame extends ImmutableComponent {
}
}
break
case messages.CAN_SWIPE_BACK:
currentWindow.webContents.send(messages.CAN_SWIPE_BACK)
break
case messages.CAN_SWIPE_FORWARD:
currentWindow.webContents.send(messages.CAN_SWIPE_FORWARD)
break
case messages.CLEAR_BROWSING_DATA_NOW:
method = (clearBrowsingDataDetail) =>
windowActions.setClearBrowsingDataDetail(clearBrowsingDataDetail)
Expand Down
19 changes: 2 additions & 17 deletions js/components/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ class Main extends ImmutableComponent {
// Navigates back/forward on macOS two-finger swipe
var trackingFingers = false
var swipeGesture = false
var canSwipeBack = false
var canSwipeForward = false
var isSwipeOnEdge = false
var deltaX = 0
var deltaY = 0
Expand All @@ -200,11 +198,6 @@ class Main extends ImmutableComponent {
deltaX = deltaX + e.deltaX
deltaY = deltaY + e.deltaY
time = (new Date()).getTime() - startTime
if (deltaX > 0) {
webviewActions.checkSwipe(false)
} else if (deltaX < 0) {
webviewActions.checkSwipe(true)
}
}
})
ipc.on(messages.DEBUG_REACT_PROFILE, (e, args) => {
Expand Down Expand Up @@ -233,12 +226,6 @@ class Main extends ImmutableComponent {
}, true)
}
})
ipc.on(messages.CAN_SWIPE_BACK, (e) => {
canSwipeBack = true
})
ipc.on(messages.CAN_SWIPE_FORWARD, (e) => {
canSwipeForward = true
})
ipc.on(messages.ENABLE_SWIPE_GESTURE, (e) => {
swipeGesture = true
})
Expand All @@ -255,15 +242,13 @@ class Main extends ImmutableComponent {
})
ipc.on('scroll-touch-end', function () {
if (time > 50 && trackingFingers && Math.abs(deltaY) < 50 && isSwipeOnEdge) {
if (deltaX > 70 && canSwipeForward) {
if (deltaX > 70) {
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_FORWARD)
} else if (deltaX < -70 && canSwipeBack) {
} else if (deltaX < -70) {
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_BACK)
}
}
trackingFingers = false
canSwipeBack = false
canSwipeForward = false
deltaX = 0
deltaY = 0
startTime = 0
Expand Down
4 changes: 0 additions & 4 deletions js/constants/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ const messages = {
GO_BACK: _,
GO_FORWARD: _,
RELOAD: _,
CAN_SWIPE_BACK: _,
CAN_SWIPE_FORWARD: _,
CHECK_SWIPE_BACK: _,
CHECK_SWIPE_FORWARD: _,
ENABLE_SWIPE_GESTURE: _,
DISABLE_SWIPE_GESTURE: _,
SHOW_FLASH_NOTIFICATION: _,
Expand Down

0 comments on commit a21be2b

Please sign in to comment.