fix(registry): match GSAP center-stagger slot semantics in us-map and spain-map

Same defect class as the earlier world-map and parallax fixes: GSAP's
stagger { each, from: "center" } assigns every element a UNIQUE slot,
ordered center-out (total span = each * (n-1)). anime.stagger(value,
{ from: "center" }) instead scales delay by distance from center, so
equidistant pairs share a slot and the reveal finishes in about half
the time.

us-map: live probe (GSAP fork-point timeline vs anime, same instants)
showed the old anime reveal at 6/46/50/50 states visible at
t=1.197/2.393/3.59/4.787s against GSAP's 4/24/44/50 -- the state map
was fully lit two seconds before the GSAP baseline. Precomputed rank
delays now match GSAP exactly at every probed instant (4/24/44/50).

spain-map: same fix for the region reveal and region-label stagger.
Old anime reveal was fully lit (19/19 regions) by t=2.393s vs GSAP's
17/19; fixed version now shows 18/19 at that instant (within the
one-element tolerance already established by the world-map fix).
This commit is contained in:
Miguel Angel Simon Sierra
2026-07-10 14:18:12 -04:00
parent 3a0049a1cd
commit 8e5bd11aa4
2 changed files with 58 additions and 4 deletions
+31 -2
View File
@@ -279,9 +279,34 @@
buildTimeline();
});
// GSAP's stagger { each, from: "center" } assigns every element a
// UNIQUE slot, ordered center-out (total span = each * (n-1)).
// anime.stagger(value, { from: "center" }) instead scales delay by
// DISTANCE from center, so equidistant pairs share a slot and the
// whole reveal finishes in about half the time. Precompute the GSAP
// rank order (sort by distance, ties lower-index-first) and hand
// anime explicit per-element delays instead.
function buildCenterStaggerRanks(count) {
var centerIdx = (count - 1) / 2;
var order = [];
for (var i = 0; i < count; i++) order.push(i);
order.sort(function (a, b) {
var da = Math.abs(a - centerIdx);
var db = Math.abs(b - centerIdx);
return da === db ? a - b : da - db;
});
var rank = new Array(count);
for (var r = 0; r < order.length; r++) {
rank[order[r]] = r;
}
return rank;
}
function buildTimeline() {
var regionPaths = regionsGroup.querySelectorAll(".region-path");
var regionLabels = labelsGroup.querySelectorAll(".region-label");
var regionPathRanks = buildCenterStaggerRanks(regionPaths.length);
var regionLabelRanks = buildCenterStaggerRanks(regionLabels.length);
tl.add(
"#spain-map .headline",
@@ -309,7 +334,9 @@
opacity: 1,
scale: 1,
duration: 400,
delay: anime.stagger(80, { from: "center" }),
delay: function (target, i) {
return regionPathRanks[i] * 80;
},
ease: "outBack(1.4)",
},
1000,
@@ -320,7 +347,9 @@
{
opacity: 1,
duration: 300,
delay: anime.stagger(50, { from: "center" }),
delay: function (target, i) {
return regionLabelRanks[i] * 50;
},
ease: "outCubic",
},
4000,
+27 -2
View File
@@ -288,9 +288,34 @@
buildTimeline();
});
// GSAP's stagger { each, from: "center" } assigns every element a
// UNIQUE slot, ordered center-out (total span = each * (n-1)).
// anime.stagger(value, { from: "center" }) instead scales delay by
// DISTANCE from center, so equidistant pairs share a slot and the
// whole reveal finishes in about half the time. Precompute the GSAP
// rank order (sort by distance, ties lower-index-first) and hand
// anime explicit per-element delays instead.
function buildCenterStaggerRanks(count) {
const centerIdx = (count - 1) / 2;
const order = [];
for (let i = 0; i < count; i++) order.push(i);
order.sort((a, b) => {
const da = Math.abs(a - centerIdx);
const db = Math.abs(b - centerIdx);
return da === db ? a - b : da - db;
});
const rank = new Array(count);
order.forEach((idx, r) => {
rank[idx] = r;
});
return rank;
}
function buildTimeline() {
const statePaths = statesGroup.querySelectorAll(".state-path");
const stateLabels = labelsGroup.querySelectorAll(".state-label");
const statePathRanks = buildCenterStaggerRanks(statePaths.length);
const stateLabelRanks = buildCenterStaggerRanks(stateLabels.length);
tl.add(
"#us-map .headline",
@@ -318,7 +343,7 @@
opacity: 1,
scale: 1,
duration: 400,
delay: anime.stagger(60, { from: "center" }),
delay: (target, i) => statePathRanks[i] * 60,
ease: "outBack(1.4)",
},
1000,
@@ -329,7 +354,7 @@
{
opacity: 1,
duration: 300,
delay: anime.stagger(40, { from: "center" }),
delay: (target, i) => stateLabelRanks[i] * 40,
ease: "outCubic",
},
3500,