1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2024-11-23 17:42:46 +01:00
TweetDuck/resources/Content/tweetdeck/globals/get_hovered_column.js

24 lines
586 B
JavaScript

import { TD } from "../../api/td.js";
/**
* Returns an object containing data about the column below the cursor.
* @returns {{ ele: Element, obj: TD_Column }|null}
*/
export function getHoveredColumn() {
const hovered = document.querySelectorAll(":hover");
for (let index = hovered.length - 1; index >= 0; index--) {
const ele = hovered[index];
if (ele.tagName === "SECTION" && ele.classList.contains("js-column")) {
const obj = TD.controller.columnManager.get(ele.getAttribute("data-column"));
if (obj) {
return { ele, obj };
}
}
}
return null;
}