mini-animate.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. return {
  2. "echasnovski/mini.animate",
  3. opts = function()
  4. -- don't use animate when scrolling with the mouse
  5. local mouse_scrolled = false
  6. for _, scroll in ipairs({ "Up", "Down" }) do
  7. local key = "<ScrollWheel" .. scroll .. ">"
  8. vim.keymap.set({ "", "i" }, key, function()
  9. mouse_scrolled = true
  10. return key
  11. end, { expr = true })
  12. end
  13. local animate = require("mini.animate")
  14. return {
  15. resize = {
  16. timing = animate.gen_timing.linear({ duration = 100, unit = "total" }),
  17. },
  18. scroll = {
  19. timing = animate.gen_timing.linear({ duration = 150, unit = "total" }),
  20. subscroll = animate.gen_subscroll.equal({
  21. predicate = function(total_scroll)
  22. if mouse_scrolled then
  23. mouse_scrolled = false
  24. return false
  25. end
  26. return total_scroll > 1
  27. end,
  28. }),
  29. },
  30. }
  31. end,
  32. }