Skip to content

Commit fcb7cc6

Browse files
authored
feat: slide_out animation (#300)
1 parent 228a969 commit fcb7cc6

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

lua/notify/config/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ local BUILTIN_RENDERERS = {
1313
local BUILTIN_STAGES = {
1414
FADE = "fade",
1515
SLIDE = "slide",
16+
SLIDE_OUT = "slide_out",
1617
FADE_IN_SLIDE_OUT = "fade_in_slide_out",
1718
STATIC = "static",
1819
}

lua/notify/stages/slide_out.lua

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
local stages_util = require("notify.stages.util")
2+
3+
return function(direction)
4+
return {
5+
function(state)
6+
local next_height = state.message.height + 2
7+
local next_row = stages_util.available_slot(state.open_windows, next_height, direction)
8+
if not next_row then
9+
return nil
10+
end
11+
return {
12+
relative = "editor",
13+
anchor = "NE",
14+
width = state.message.width,
15+
height = state.message.height,
16+
col = vim.opt.columns:get(),
17+
row = next_row,
18+
border = "rounded",
19+
style = "minimal",
20+
}
21+
end,
22+
function(state, win)
23+
return {
24+
col = vim.opt.columns:get(),
25+
time = true,
26+
row = stages_util.slot_after_previous(win, state.open_windows, direction),
27+
}
28+
end,
29+
function(state, win)
30+
return {
31+
width = {
32+
1,
33+
frequency = 2.5,
34+
damping = 0.9,
35+
complete = function(cur_width)
36+
return cur_width < 3
37+
end,
38+
},
39+
col = { vim.opt.columns:get() },
40+
row = {
41+
stages_util.slot_after_previous(win, state.open_windows, direction),
42+
frequency = 3,
43+
complete = function()
44+
return true
45+
end,
46+
},
47+
}
48+
end,
49+
}
50+
end

0 commit comments

Comments
 (0)