mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fit/fix flash duration animation to length
This commit is contained in:
@ -55,16 +55,11 @@
|
|||||||
|
|
||||||
/* Flashing for highlighting animation */
|
/* Flashing for highlighting animation */
|
||||||
@keyframes flash {
|
@keyframes flash {
|
||||||
|
0%, 50%, 100% {
|
||||||
20%,
|
|
||||||
60%,
|
|
||||||
100% {
|
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
0%,
|
25%, 75% {
|
||||||
40%,
|
|
||||||
80% {
|
|
||||||
opacity: 0.2;
|
opacity: 0.2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1571,13 +1571,29 @@ export function setValueByPath(obj, path, value) {
|
|||||||
/**
|
/**
|
||||||
* Flashes the given HTML element via CSS flash animation for a defined period
|
* Flashes the given HTML element via CSS flash animation for a defined period
|
||||||
* @param {JQuery<HTMLElement>} element - The element to flash
|
* @param {JQuery<HTMLElement>} element - The element to flash
|
||||||
* @param {number} timespan - A numer in milliseconds how the flash should last
|
* @param {number} timespan - A number in milliseconds how the flash should last (default is 2000ms. Multiples of 1000ms work best, as they end with the flash animation being at 100% opacity)
|
||||||
*/
|
*/
|
||||||
export function flashHighlight(element, timespan = 2000) {
|
export function flashHighlight(element, timespan = 2000) {
|
||||||
|
const flashDuration = 2000; // Duration of a single flash cycle in milliseconds
|
||||||
|
|
||||||
element.addClass('flash animated');
|
element.addClass('flash animated');
|
||||||
setTimeout(() => element.removeClass('flash animated'), timespan);
|
element.css('--animation-duration', `${flashDuration}ms`);
|
||||||
|
|
||||||
|
// Repeat the flash animation
|
||||||
|
const intervalId = setInterval(() => {
|
||||||
|
element.removeClass('flash animated');
|
||||||
|
void element[0].offsetWidth; // Trigger reflow to restart animation
|
||||||
|
element.addClass('flash animated');
|
||||||
|
}, flashDuration);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
clearInterval(intervalId);
|
||||||
|
element.removeClass('flash animated');
|
||||||
|
element.css('--animation-duration', '');
|
||||||
|
}, timespan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the given control has an animation applied to it
|
* Checks if the given control has an animation applied to it
|
||||||
*
|
*
|
||||||
|
@ -208,8 +208,8 @@ table.responsiveTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.animated {
|
.animated {
|
||||||
-webkit-animation-duration: 3s !important;
|
-webkit-animation-duration: var(--animation-duration, 3s) !important;
|
||||||
animation-duration: 3s !important;
|
animation-duration: var(--animation-duration, 3s) !important;
|
||||||
-webkit-animation-fill-mode: both !important;
|
-webkit-animation-fill-mode: both !important;
|
||||||
animation-fill-mode: both !important;
|
animation-fill-mode: both !important;
|
||||||
box-shadow: inset 0 0 5px var(--SmartThemeQuoteColor);
|
box-shadow: inset 0 0 5px var(--SmartThemeQuoteColor);
|
||||||
|
Reference in New Issue
Block a user