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

Commit

Permalink
Provide a swipe navigation sensitivity setting for users to config
Browse files Browse the repository at this point in the history
fixes #9615

Auditors: @cezaraugusto, @bbondy, @bradleyrichter

Test Plan:
1. Adjust swipe navigation sesitivity setting in
about:preferences#advanced
2. And swipe to navigate by different settings
  • Loading branch information
darkdh committed Jun 20, 2017
1 parent 1007e8c commit 244bf63
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app/extensions/brave/locales/en-US/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ useHardwareAcceleration=Use hardware acceleration when available *
useSmoothScroll=Enable smooth scrolling *
defaultZoomLevel=Default zoom level
toolbarUserInterfaceScale=Toolbar and UI elements scale
swipeNavigationSensitivity=Swipe Navigation Sensitivity
fast=Fast
slow=Slow
en-US=English (U.S.)
nl-NL=Dutch (Netherlands)
pt-BR=Portuguese (Brazil)
Expand Down
5 changes: 3 additions & 2 deletions app/renderer/components/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,11 @@ class Main extends ImmutableComponent {
}, { passive: true })

ipc.on('scroll-touch-end', () => {
const threshold = getSetting(settings.SWIPE_NAV_SENSITIVITY)
if (trackingFingers && time > 30 && Math.abs(deltaY) < 80) {
if (deltaX > 70 && isSwipeOnRightEdge) {
if (deltaX > threshold && isSwipeOnRightEdge) {
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_FORWARD)
} else if (deltaX < -70 && isSwipeOnLeftEdge) {
} else if (deltaX < -threshold && isSwipeOnLeftEdge) {
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_BACK)
}
}
Expand Down
39 changes: 39 additions & 0 deletions app/renderer/components/preferences/advancedTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,32 @@ const {scaleSize} = require('../../../common/constants/toolbarUserInterfaceScale

// Utils
const {changeSetting} = require('../../lib/settingsUtil')
const platformUtil = require('../../../common/lib/platformUtil')

class AdvancedTab extends ImmutableComponent {
get swipeNavigationSensitivitySetting () {
if (platformUtil.isDarwin()) {
return <div>
<DefaultSectionTitle data-l10n-id='swipeNavigationSensitivity' />
<SettingsList listClassName={css(styles.swipeNavigation)}>
<span data-l10n-id='fast' className={css(styles.swipeNavigation__fastLabel)} />
<input type='range' min='0' max='200' step='50' list='swipetSensitivity'
value={getSetting(settings.SWIPE_NAV_SENSITIVITY, this.props.settings)}
onChange={changeSetting.bind(null, this.props.onChangeSetting, settings.SWIPE_NAV_SENSITIVITY)} />
<datalist id='swipetSensitivity'>
<option value='0' />
<option value='50' />
<option value='100' />
<option value='150' />
<option value='200' />
</datalist>
<span data-l10n-id='slow' className={css(styles.swipeNavigation__slowLabel)} />
</SettingsList>
</div>
}

return null
}
render () {
return <section>
<main className={css(styles.advancedTabMain)}>
Expand Down Expand Up @@ -50,6 +74,8 @@ class AdvancedTab extends ImmutableComponent {
</SettingItem>
</SettingsList>

{this.swipeNavigationSensitivitySetting}

<DefaultSectionTitle data-l10n-id='urlBarOptions' />
<SettingsList>
<SettingCheckbox dataL10nId='disableTitleMode' prefKey={settings.DISABLE_TITLE_MODE} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
Expand All @@ -68,6 +94,19 @@ const styles = StyleSheet.create({
paddingBottom: '40px'
},

swipeNavigation: {
display: 'flex',
alignItems: 'center'
},

swipeNavigation__fastLabel: {
marginRight: '5px'
},

swipeNavigation__slowLabel: {
marginLeft: '5px'
},

moreInfo: {
display: 'flex',
flex: 1,
Expand Down
1 change: 1 addition & 0 deletions js/constants/appConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ module.exports = {
'advanced.auto-suggest-sites': true,
'advanced.hide-lower-sites': true,
'advanced.toolbar-ui-scale': 'normal',
'advanced.swipe-swipe-nav-sensitivity': 100,
'shutdown.clear-history': false,
'shutdown.clear-downloads': false,
'shutdown.clear-cache': false,
Expand Down
1 change: 1 addition & 0 deletions js/constants/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const settings = {
MINIMUM_VISITS: 'advanced.minimum-visits',
AUTO_SUGGEST_SITES: 'advanced.auto-suggest-sites',
TOOLBAR_UI_SCALE: 'advanced.toolbar-ui-scale',
SWIPE_NAV_SENSITIVITY: 'advanced.swipe-nav-sensitivity',
// Sync settings
SYNC_ENABLED: 'sync.enabled',
SYNC_DEVICE_NAME: 'sync.device-name',
Expand Down

0 comments on commit 244bf63

Please sign in to comment.