use RmlUi animation syntax for toast
Animation syntax: <duration> <tweening-function> <keyframes-name> - toast-show class triggers toast-in animation (slide up, fade in) - toast-hide class triggers toast-out animation (slide down, fade out)
This commit is contained in:
@@ -252,30 +252,23 @@ function showToast(message, type)
|
|||||||
type_class = " toast-warning"
|
type_class = " toast-warning"
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Create toast in hidden state (opacity 0, translated down)
|
-- Create toast with show animation class
|
||||||
local toast_html = '<div id="active-toast" class="toast' .. type_class .. '"><span>' .. message .. '</span></div>'
|
local toast_html = '<div id="active-toast" class="toast toast-show' .. type_class .. '"><span>' .. message .. '</span></div>'
|
||||||
container.inner_rml = toast_html
|
container.inner_rml = toast_html
|
||||||
|
|
||||||
-- Add toast-show class after brief delay to trigger transition
|
-- Auto-hide after 2.5 seconds
|
||||||
if setTimeout then
|
if setTimeout then
|
||||||
setTimeout(function()
|
|
||||||
local toast = shell_document:GetElementById("active-toast")
|
|
||||||
if toast then
|
|
||||||
toast:SetClass("toast-show", true)
|
|
||||||
end
|
|
||||||
end, 10)
|
|
||||||
|
|
||||||
-- Auto-hide after 2.5 seconds
|
|
||||||
active_toast_id = setTimeout(function()
|
active_toast_id = setTimeout(function()
|
||||||
local toast = shell_document:GetElementById("active-toast")
|
local toast = shell_document:GetElementById("active-toast")
|
||||||
if toast then
|
if toast then
|
||||||
-- Remove show class to animate out
|
-- Switch to hide animation
|
||||||
toast:SetClass("toast-show", false)
|
toast:SetClass("toast-show", false)
|
||||||
-- Remove element after transition
|
toast:SetClass("toast-hide", true)
|
||||||
|
-- Remove element after animation
|
||||||
setTimeout(function()
|
setTimeout(function()
|
||||||
container.inner_rml = ""
|
container.inner_rml = ""
|
||||||
active_toast_id = nil
|
active_toast_id = nil
|
||||||
end, 300)
|
end, 250)
|
||||||
end
|
end
|
||||||
end, 2500)
|
end, 2500)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -125,16 +125,36 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
/* Initial hidden state */
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateY(30dp);
|
|
||||||
/* Transition for smooth animation */
|
|
||||||
transition: opacity transform 0.3s back-out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.toast-show {
|
.toast-show {
|
||||||
opacity: 1;
|
animation: 0.3s back-out toast-in;
|
||||||
transform: translateY(0);
|
}
|
||||||
|
|
||||||
|
.toast-hide {
|
||||||
|
animation: 0.25s quadratic-in toast-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes toast-in {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(30dp);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes toast-out {
|
||||||
|
from {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(30dp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.toast-success {
|
.toast-success {
|
||||||
|
|||||||
Reference in New Issue
Block a user