@hgdc/ui 0.16.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/family-loader.js +8 -1
- package/package.json +1 -1
package/dist/family-loader.js
CHANGED
|
@@ -16,12 +16,19 @@ export function familyLoaderStartTime(timeOrigin, period = FAMILY_LOADER_PERIOD_
|
|
|
16
16
|
export function familyLoaderPhase(epochMs, period = FAMILY_LOADER_PERIOD_MS) {
|
|
17
17
|
return ((epochMs % period) + period) % period;
|
|
18
18
|
}
|
|
19
|
+
function isLoaderAnimation(animation) {
|
|
20
|
+
const name = animation.animationName;
|
|
21
|
+
return typeof name === "string" && name.startsWith("family-loader");
|
|
22
|
+
}
|
|
19
23
|
/** Cale toutes les animations du H sous `root` sur l'horloge (voir `familyLoaderStartTime`). */
|
|
20
24
|
export function syncFamilyLoader(root) {
|
|
21
25
|
if (!root || typeof root.getAnimations !== "function")
|
|
22
26
|
return;
|
|
23
27
|
const start = familyLoaderStartTime(performance.timeOrigin);
|
|
24
28
|
for (const animation of root.getAnimations({ subtree: true })) {
|
|
29
|
+
// Les animations du H seulement : une transition (fondu du chargeur) garde son propre départ.
|
|
30
|
+
if (!isLoaderAnimation(animation))
|
|
31
|
+
continue;
|
|
25
32
|
if (animation.startTime !== start)
|
|
26
33
|
animation.startTime = start;
|
|
27
34
|
}
|
|
@@ -31,7 +38,7 @@ export function syncFamilyLoader(root) {
|
|
|
31
38
|
* avant l'hydratation, une fois la feuille de style chargée (un script attend les feuilles de
|
|
32
39
|
* style qui le précèdent). Une animation recréée (mouvement réduit basculé) se recale aussi.
|
|
33
40
|
*/
|
|
34
|
-
const SYNC_SCRIPT = `(function(e){if(!e||!e.getAnimations)return;var p=${FAMILY_LOADER_PERIOD_MS};function s(){var t=-(((performance.timeOrigin%p)+p)%p);e.getAnimations({subtree:true}).forEach(function(a){if(a.startTime!==t)a.startTime=t})}s();e.addEventListener("animationstart",s)})(document.currentScript&&document.currentScript.previousElementSibling)`;
|
|
41
|
+
const SYNC_SCRIPT = `(function(e){if(!e||!e.getAnimations)return;var p=${FAMILY_LOADER_PERIOD_MS};function s(){var t=-(((performance.timeOrigin%p)+p)%p);e.getAnimations({subtree:true}).forEach(function(a){if(String(a.animationName).indexOf("family-loader")===0&&a.startTime!==t)a.startTime=t})}s();e.addEventListener("animationstart",s)})(document.currentScript&&document.currentScript.previousElementSibling)`;
|
|
35
42
|
const useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
36
43
|
/** Cale le H sur l'horloge au montage et à chaque animation recréée. */
|
|
37
44
|
function useClockSync(ref) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hgdc/ui",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"description": "Interface de la H family : jetons de la DA, thèmes, polices et composants.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"homepage": "https://github.com/hugogebel-boop/hgdc-kit/tree/main/packages/ui#readme",
|