Merge pull request #1573 from shashank1207/scroll-by-space

Add setting to change space needed to scroll by pressing space
pull/1579/head
Bryan Hernández 4 years ago committed by GitHub
commit 33d0540418
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,6 +13,8 @@ class app.Settings
'size'
'tips'
'autoInstall'
'spaceScroll'
'spaceTimeout'
]
INTERNAL_KEYS = [
@ -33,6 +35,8 @@ class app.Settings
schema: 1
analyticsConsent: false
theme: 'auto'
spaceScroll: 1
spaceTimeout: 0.5
constructor: ->
@store = new CookiesStore

@ -18,10 +18,16 @@ class app.Shortcuts
swapArrowKeysBehavior: ->
app.settings.get('arrowScroll')
spaceScroll: ->
app.settings.get('spaceScroll')
showTip: ->
app.showTip('KeyNav')
@showTip = null
spaceTimeout: ->
app.settings.get('spaceTimeout')
onKeydown: (event) =>
return if @buggyEvent(event)
result = if event.ctrlKey or event.metaKey
@ -59,7 +65,7 @@ class app.Shortcuts
@trigger 'escape'
false
when 32
if event.target.type is 'search' and (not @lastKeypress or @lastKeypress < Date.now() - 500)
if event.target.type is 'search' and @spaceScroll() and (not @lastKeypress or @lastKeypress < Date.now() - (@spaceTimeout() * 1000))
@trigger 'pageDown'
false
when 33

@ -56,6 +56,13 @@ app.templates.settingsPage = (settings) -> """
<input type="checkbox" form="settings" name="arrowScroll" value="1"#{if settings.arrowScroll then ' checked' else ''}>Use arrow keys to scroll the main content area
<small>With this checked, use <code class="_label">shift</code> + <code class="_label">&uarr;</code><code class="_label">&darr;</code><code class="_label">&larr;</code><code class="_label">&rarr;</code> to navigate the sidebar.</small>
</label>
<label class="_settings-label">
<input type="checkbox" form="settings" name="spaceScroll" value="1"#{if settings.spaceScroll then ' checked' else ''}>Use spacebar to scroll during search
</label>
<label class="_settings-label">
<input type="number" form="settings" name="spaceTimeout" min="0" max="5" value="#{settings.spaceTimeout}"> Delay until you can scroll by pressing space
<small>Time in seconds</small>
</label>
</div>
</div>

@ -16,6 +16,8 @@ class app.views.SettingsPage extends app.View
settings.arrowScroll = app.settings.get('arrowScroll')
settings.autoInstall = app.settings.get('autoInstall')
settings.analyticsConsent = app.settings.get('analyticsConsent')
settings.spaceScroll = app.settings.get('spaceScroll')
settings.spaceTimeout = app.settings.get('spaceTimeout')
settings.autoSupported = app.settings.autoSupported
settings[layout] = app.settings.hasLayout(layout) for layout in app.settings.LAYOUTS
settings
@ -40,6 +42,13 @@ class app.views.SettingsPage extends app.View
resetAnalytics() unless enable
return
toggleSpaceScroll: (enable) ->
app.settings.set('spaceScroll', if enable then 1 else 0)
return
setScrollTimeout: (value) ->
app.settings.set('spaceTimeout', value)
toggle: (name, enable) ->
app.settings.set(name, enable)
return
@ -85,6 +94,10 @@ class app.views.SettingsPage extends app.View
@import input.files[0], input
when 'analyticsConsent'
@toggleAnalyticsConsent input.checked
when 'spaceScroll'
@toggleSpaceScroll input.checked
when 'spaceTimeout'
@setScrollTimeout input.value
else
@toggle input.name, input.checked
return

Loading…
Cancel
Save