withFocusedPanelId.ts 366 B

123456789101112
  1. export function withFocusedPanel(fn: (panelId: number) => void) {
  2. return () => {
  3. const elements = document.querySelectorAll(':hover');
  4. for (let i = elements.length - 1; i > 0; i--) {
  5. const element = elements[i] as unknown as HTMLElement;
  6. if (element.dataset?.panelid) {
  7. fn(parseInt(element.dataset?.panelid, 10));
  8. }
  9. }
  10. };
  11. }