Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the stop function and use it if the user tries scroll the opposite direction #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions autoload/comfortable_motion.vim
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,22 @@ endfunction

function! comfortable_motion#flick(impulse)
if !exists('s:timer_id')
" There is no thread, start one
" there is no thread, start one
let l:interval = float2nr(round(g:comfortable_motion_interval))
let s:timer_id = timer_start(l:interval, function("s:tick"), {'repeat': -1})
endif
let s:comfortable_motion_state.impulse += a:impulse
" If the current velocity if not going in the same direction as the command
if a:impulse > 0 && s:comfortable_motion_state.velocity < 0 || a:impulse < 0 && s:comfortable_motion_state.velocity > 0
" Stop the scolling
call comfortable_motion#stop()
else
" Add the impulse to the scolling
let s:comfortable_motion_state.impulse += a:impulse
endif
endfunction

function! comfortable_motion#stop()
let s:comfortable_motion_state.velocity = 0.0
endfunction

let &cpo = s:save_cpo
Expand Down