energy-visualization-sankey 1.0.20 → 1.0.22
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/sankey.esm.js
CHANGED
|
@@ -8147,19 +8147,28 @@ class AnimationService {
|
|
|
8147
8147
|
const minYear = this.dataService.firstYear;
|
|
8148
8148
|
const maxYear = this.dataService.lastYear;
|
|
8149
8149
|
// Calculate precise positioning
|
|
8150
|
-
const position = this.calculateIndicatorPosition(slider, currentYear, minYear, maxYear);
|
|
8150
|
+
const position = this.calculateIndicatorPosition(slider, indicator, currentYear, minYear, maxYear);
|
|
8151
8151
|
// Apply positioning and content
|
|
8152
8152
|
this.applyIndicatorPosition(indicator, position, currentYear);
|
|
8153
8153
|
}
|
|
8154
|
-
calculateIndicatorPosition(slider, currentYear, minYear, maxYear) {
|
|
8154
|
+
calculateIndicatorPosition(slider, indicator, currentYear, minYear, maxYear) {
|
|
8155
8155
|
const sliderRect = slider.getBoundingClientRect();
|
|
8156
|
+
const offsetParent = indicator.offsetParent;
|
|
8157
|
+
// parentLeft is the viewport-relative left edge of whatever element the indicator's
|
|
8158
|
+
// `left` CSS property is measured from. This varies between plain HTML and framework
|
|
8159
|
+
// environments (Nuxt, Vue, etc.) depending on which ancestor has position != static.
|
|
8160
|
+
const parentLeft = offsetParent ? offsetParent.getBoundingClientRect().left : 0;
|
|
8156
8161
|
const progress = (currentYear - minYear) / (maxYear - minYear);
|
|
8157
|
-
// Account for thumb dimensions (11px width from CSS)
|
|
8158
8162
|
const thumbWidth = 11;
|
|
8159
8163
|
const effectiveWidth = sliderRect.width - thumbWidth;
|
|
8160
|
-
|
|
8161
|
-
//
|
|
8162
|
-
|
|
8164
|
+
// Compute thumb center in viewport coordinates, then translate to offset-parent space.
|
|
8165
|
+
// Using getBoundingClientRect differences means scroll position cancels out automatically.
|
|
8166
|
+
const thumbCenterViewport = sliderRect.left + (thumbWidth / 2) + (progress * effectiveWidth);
|
|
8167
|
+
// Use the actual rendered width so centering is correct regardless of whether the host
|
|
8168
|
+
// project applies box-sizing: border-box (e.g. Nuxt/Vue resets) or content-box (plain HTML).
|
|
8169
|
+
// offsetWidth always reflects the true painted width including padding.
|
|
8170
|
+
const indicatorWidth = indicator.offsetWidth;
|
|
8171
|
+
return (thumbCenterViewport - parentLeft) - (indicatorWidth / 2);
|
|
8163
8172
|
}
|
|
8164
8173
|
applyIndicatorPosition(indicator, position, year) {
|
|
8165
8174
|
indicator.style.left = `${position}px`;
|