From 6d6203ce85fdb913bfa7394112d5f754d17b5333 Mon Sep 17 00:00:00 2001 From: Charlie <1667482085@qq.com> Date: Mon, 1 Jul 2024 20:35:55 +0800 Subject: [PATCH] fix(animate): avoid lagging when doing a lot of relative resizing --- .../plugins/extras/ui/mini-animate.lua | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/lua/lazyvim/plugins/extras/ui/mini-animate.lua b/lua/lazyvim/plugins/extras/ui/mini-animate.lua index c1f44d6d..e6e97cd8 100644 --- a/lua/lazyvim/plugins/extras/ui/mini-animate.lua +++ b/lua/lazyvim/plugins/extras/ui/mini-animate.lua @@ -18,6 +18,13 @@ return { return { resize = { timing = animate.gen_timing.linear({ duration = 50, unit = "total" }), + -- diable animate when resize acitve + -- best effort to avoid lagging when doing a lot of relative resizing + subresize = animate.gen_subresize.equal({ + predicate = function() + return not animate.is_active("resize") + end, + }), }, scroll = { timing = animate.gen_timing.linear({ duration = 150, unit = "total" }), @@ -33,4 +40,36 @@ return { }, } end, + -- because of "VeryLazy" event, "MiniAnimate" module has already been exported + -- make LazyVim key maps smoother + keys = { + { + "", + function() + MiniAnimate.execute_after("resize", "resize +2") + end, + desc = "Increase Window Height", + }, + { + "", + function() + MiniAnimate.execute_after("resize", "resize -2") + end, + desc = "Decrease Window Height", + }, + { + "", + function() + MiniAnimate.execute_after("resize", "vertical resize -2") + end, + desc = "Decrease Window Width", + }, + { + "", + function() + MiniAnimate.execute_after("resize", "vertical resize +2") + end, + desc = "Increase Window Width", + }, + }, }