Skip to content

Commit

Permalink
docs(animate): document issues with scrolling via j/k with 'wrap'
Browse files Browse the repository at this point in the history
Details:
- Do not make this default as it is mostly needed for scroll animation
  (resize can't be repeated by holding key *and* each scroll being for
  more than a single cell). Setting it only to `animate.timing` breaks
  the symmetry of the same timing across all animations.

  Besides, scrolling via holding `j`/`k` should be avoided *and* exact
  cutoff of maximum step duration depends on the OS settings for the key
  repeat rate.

Resolve #1588
Resolve #242
  • Loading branch information
echasnovski committed Feb 20, 2025
1 parent 65445ad commit dc17756
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
20 changes: 13 additions & 7 deletions doc/mini-animate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Default values:
enable = true,

-- Timing of animation (how steps will progress in time)
timing = --<function: implements linear total 250ms animation duration>,
timing = --<function: linear animation, total 250ms>,

-- Path generator for visualized cursor movement
path = --<function: implements shortest line path no longer than 1000>,
Expand All @@ -140,7 +140,7 @@ Default values:
enable = true,

-- Timing of animation (how steps will progress in time)
timing = --<function: implements linear total 250ms animation duration>,
timing = --<function: linear animation, total 250ms>,

-- Subscroll generator based on total scroll
subscroll = --<function: implements equal scroll with at most 60 steps>,
Expand All @@ -152,7 +152,7 @@ Default values:
enable = true,

-- Timing of animation (how steps will progress in time)
timing = --<function: implements linear total 250ms animation duration>,
timing = --<function: linear animation, total 250ms>,

-- Subresize generator for all steps of resize animations
subresize = --<function: implements equal linear steps>,
Expand All @@ -164,7 +164,7 @@ Default values:
enable = true,

-- Timing of animation (how steps will progress in time)
timing = --<function: implements linear total 250ms animation duration>,
timing = --<function: linear animation, total 250ms>,

-- Floating window config generator visualizing specific window
winconfig = --<function: implements static window for 25 steps>,
Expand All @@ -179,7 +179,7 @@ Default values:
enable = true,

-- Timing of animation (how steps will progress in time)
timing = --<function: implements linear total 250ms animation duration>,
timing = --<function: linear animation, total 250ms>,

-- Floating window config generator visualizing specific window
winconfig = --<function: implements static window for 25 steps>,
Expand Down Expand Up @@ -293,8 +293,14 @@ Notes:
'<Cmd>lua vim.cmd("normal! n"); ' ..
'MiniAnimate.execute_after("scroll", "normal! zvzz")<CR>'
<
- This animation works best with Neovim>=0.9 (after certain updates to
|WinScrolled| event).
- Default timing might conflict with scrolling via holding a key (like `j` or `k`
with 'wrap' enabled) due to high key repeat rate: next scroll is done before
first step of current one finishes. Resolve this by not scrolling like that
or by ensuring maximum value of step duration to be lower than between
repeated keys: set timing like `function(_, n) return math.min(250/n, 10) end`
or use timing with constant step duration.
- This animation works best with Neovim>=0.9 (after certain updates
to |WinScrolled| event).

Configuration example: >lua

Expand Down
20 changes: 13 additions & 7 deletions lua/mini/animate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,14 @@ end
--- '<Cmd>lua vim.cmd("normal! n"); ' ..
--- 'MiniAnimate.execute_after("scroll", "normal! zvzz")<CR>'
--- <
--- - This animation works best with Neovim>=0.9 (after certain updates to
--- |WinScrolled| event).
--- - Default timing might conflict with scrolling via holding a key (like `j` or `k`
--- with 'wrap' enabled) due to high key repeat rate: next scroll is done before
--- first step of current one finishes. Resolve this by not scrolling like that
--- or by ensuring maximum value of step duration to be lower than between
--- repeated keys: set timing like `function(_, n) return math.min(250/n, 10) end`
--- or use timing with constant step duration.
--- - This animation works best with Neovim>=0.9 (after certain updates
--- to |WinScrolled| event).
---
--- Configuration example: >lua
---
Expand Down Expand Up @@ -400,7 +406,7 @@ MiniAnimate.config = {
enable = true,

-- Timing of animation (how steps will progress in time)
--minidoc_replace_start timing = --<function: implements linear total 250ms animation duration>,
--minidoc_replace_start timing = --<function: linear animation, total 250ms>,
timing = function(_, n) return 250 / n end,
--minidoc_replace_end

Expand All @@ -418,7 +424,7 @@ MiniAnimate.config = {
enable = true,

-- Timing of animation (how steps will progress in time)
--minidoc_replace_start timing = --<function: implements linear total 250ms animation duration>,
--minidoc_replace_start timing = --<function: linear animation, total 250ms>,
timing = function(_, n) return 250 / n end,
--minidoc_replace_end

Expand All @@ -436,7 +442,7 @@ MiniAnimate.config = {
enable = true,

-- Timing of animation (how steps will progress in time)
--minidoc_replace_start timing = --<function: implements linear total 250ms animation duration>,
--minidoc_replace_start timing = --<function: linear animation, total 250ms>,
timing = function(_, n) return 250 / n end,
--minidoc_replace_end

Expand All @@ -454,7 +460,7 @@ MiniAnimate.config = {
enable = true,

-- Timing of animation (how steps will progress in time)
--minidoc_replace_start timing = --<function: implements linear total 250ms animation duration>,
--minidoc_replace_start timing = --<function: linear animation, total 250ms>,
timing = function(_, n) return 250 / n end,
--minidoc_replace_end

Expand All @@ -477,7 +483,7 @@ MiniAnimate.config = {
enable = true,

-- Timing of animation (how steps will progress in time)
--minidoc_replace_start timing = --<function: implements linear total 250ms animation duration>,
--minidoc_replace_start timing = --<function: linear animation, total 250ms>,
timing = function(_, n) return 250 / n end,
--minidoc_replace_end

Expand Down

0 comments on commit dc17756

Please sign in to comment.