mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-22 02:19:54 +02:00
[Feature] Improved Countdown Animations (#2010)
Some checks failed
Project CI / build (24.x) (push) Has been cancelled
Some checks failed
Project CI / build (24.x) (push) Has been cancelled
This commit is contained in:
parent
d2e87e4eb9
commit
975c655828
3 changed files with 37 additions and 58 deletions
|
|
@ -13,7 +13,6 @@ const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||||
export default class DhCountdowns extends HandlebarsApplicationMixin(ApplicationV2) {
|
export default class DhCountdowns extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||||
previousCountdownData = null;
|
previousCountdownData = null;
|
||||||
changedCountdownsForAnimation = new Set();
|
changedCountdownsForAnimation = new Set();
|
||||||
countdownChangeAnimationTimeout = null;
|
|
||||||
|
|
||||||
constructor(options = {}) {
|
constructor(options = {}) {
|
||||||
super(options);
|
super(options);
|
||||||
|
|
@ -95,35 +94,41 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
||||||
.countdowns;
|
.countdowns;
|
||||||
|
|
||||||
/* Handle animations to draw attention to countdown values changing */
|
/* Handle animations to draw attention to countdown values changing */
|
||||||
if (this.changedCountdownsForAnimation.size) {
|
const typesToAnimate = new Set();
|
||||||
if (this.countdownChangeAnimationTimeout)
|
|
||||||
clearTimeout(this.countdownChangeAnimationTimeout);
|
|
||||||
|
|
||||||
this.countdownChangeAnimationTimeout = setTimeout(() => {
|
|
||||||
this.changedCountdownsForAnimation.clear();
|
|
||||||
const selector = '.countdown-container, .header-type-toggles .header-type';
|
|
||||||
for (const element of this.element.querySelectorAll(selector)) {
|
|
||||||
element.classList.remove('change-glow');
|
|
||||||
}
|
|
||||||
}, 3000);
|
|
||||||
|
|
||||||
/* If the countdown is not currently visible, add a glow to the CountdownType pill */
|
|
||||||
const visibleTypes = this.visibleCountdownTypes;
|
|
||||||
for (const countdownKey of this.changedCountdownsForAnimation) {
|
for (const countdownKey of this.changedCountdownsForAnimation) {
|
||||||
|
const shimmerAnimation = [
|
||||||
|
{ backgroundPositionX: '98%' },
|
||||||
|
{ backgroundPositionX: '0%' }
|
||||||
|
];
|
||||||
|
const shimmerTiming = {
|
||||||
|
duration: 1000,
|
||||||
|
iterations: 1
|
||||||
|
};
|
||||||
|
|
||||||
|
const element = this.element.querySelector(`.countdown-container[data-countdown="${countdownKey}"]`);
|
||||||
|
element?.animate(shimmerAnimation, shimmerTiming);
|
||||||
|
|
||||||
const countdown = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns)
|
const countdown = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns)
|
||||||
.countdowns[countdownKey];
|
.countdowns[countdownKey];
|
||||||
if (!visibleTypes.includes(countdown?.type)) {
|
if (!this.visibleCountdownTypes.includes(countdown?.type))
|
||||||
this.element.querySelector(`.header-type-toggles .header-type[data-type="${countdown.type}"]`)
|
typesToAnimate.add(countdown.type);
|
||||||
.classList.add('change-glow');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the countdown element is not rendered the user doesn't have permissions to it. No animation needed on the elment itself */
|
for (const type of typesToAnimate) {
|
||||||
const countdownElement = this.element.querySelector(`.countdown-container[data-countdown="${countdownKey}"]`);
|
const pulseAnimation = [
|
||||||
if (!countdownElement) continue;
|
{ boxShadow: '0 0 1px 1px var(--golden)' },
|
||||||
|
{ boxShadow: '0 0 2px 2px var(--golden)' }
|
||||||
|
];
|
||||||
|
const pulseTiming = {
|
||||||
|
duration: 1000,
|
||||||
|
iterations: 3
|
||||||
|
};
|
||||||
|
|
||||||
countdownElement.classList.add('change-glow');
|
const element = this.element.querySelector(`.header-type-toggles .header-type[data-type="${type}"]`);
|
||||||
}
|
element?.animate(pulseAnimation, pulseTiming);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.changedCountdownsForAnimation.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns countdown data filtered by ownership */
|
/** Returns countdown data filtered by ownership */
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ export default class DhCountdowns extends foundry.abstract.DataModel {
|
||||||
return acc;
|
return acc;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
foundry.ui.countdowns.changedCountdownsForAnimation.add(...changedCountdowns);
|
for (const countdownKey of changedCountdowns)
|
||||||
|
foundry.ui.countdowns.changedCountdownsForAnimation.add(countdownKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,10 +88,6 @@
|
||||||
&.inactive {
|
&.inactive {
|
||||||
opacity: 0.4;
|
opacity: 0.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.change-glow {
|
|
||||||
animation: glow 1s ease-in-out infinite;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -118,13 +114,9 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
|
|
||||||
&.change-glow {
|
|
||||||
animation: shimmer 1s ease-out;
|
|
||||||
background: linear-gradient(-45deg, transparent 30%, light-dark(@dark-blue-40, @golden-40) 35%, transparent 40%);
|
background: linear-gradient(-45deg, transparent 30%, light-dark(@dark-blue-40, @golden-40) 35%, transparent 40%);
|
||||||
background-size: 300%;
|
background-size: 300%;
|
||||||
background-position-x: 100%
|
background-position-x: 100%;
|
||||||
}
|
|
||||||
|
|
||||||
&.icon-only {
|
&.icon-only {
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
|
|
@ -225,23 +217,4 @@
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes glow {
|
|
||||||
0% {
|
|
||||||
box-shadow: 0 0 1px 1px @golden;
|
|
||||||
}
|
|
||||||
|
|
||||||
100% {
|
|
||||||
box-shadow: 0 0 2px 2px @golden;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes shimmer {
|
|
||||||
from {
|
|
||||||
background-position-x: 98%;
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
background-position-x: 0%
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue