2025-11-11 17:41:57 -08:00
|
|
|
/**
|
2026-02-06 11:26:51 -08:00
|
|
|
* PosePickerPopover web component
|
2025-11-11 17:41:57 -08:00
|
|
|
*
|
2026-02-06 11:26:51 -08:00
|
|
|
* Scrolls the selected style into view when the style picker list becomes
|
|
|
|
|
* visible (e.g. tab switch or popover open).
|
2025-11-11 17:41:57 -08:00
|
|
|
*/
|
2025-11-11 18:07:06 -08:00
|
|
|
class PosePickerPopover extends HTMLElement {
|
2026-02-05 18:17:34 -08:00
|
|
|
#styleListObserver;
|
2025-11-11 17:41:57 -08:00
|
|
|
|
|
|
|
|
connectedCallback() {
|
2026-02-05 18:17:34 -08:00
|
|
|
// When the style picker list becomes visible (e.g. tab switch or
|
|
|
|
|
// popover open), scroll the selected style into view.
|
|
|
|
|
const styleList = this.querySelector(".style-picker-list");
|
|
|
|
|
if (styleList) {
|
|
|
|
|
this.#styleListObserver = new IntersectionObserver(([entry]) => {
|
|
|
|
|
if (entry.isIntersecting) {
|
|
|
|
|
const checked = styleList.querySelector("input:checked");
|
|
|
|
|
checked
|
|
|
|
|
?.closest("label")
|
|
|
|
|
?.scrollIntoView({ block: "nearest" });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.#styleListObserver.observe(styleList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
disconnectedCallback() {
|
|
|
|
|
this.#styleListObserver?.disconnect();
|
2025-11-11 17:41:57 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-11 18:07:06 -08:00
|
|
|
customElements.define("pose-picker-popover", PosePickerPopover);
|