UNPKG

cognitive-complexity-ts

Version:

This program analyses TypeScript and JavaScript code according to the [Cognitive Complexity metric](https://www.sonarsource.com/docs/CognitiveComplexity.pdf). It produces a JSON summary and a GUI for exploring the complexity of your codebase.

26 lines 825 B
import { addStyleSheet, element } from "../../framework.js"; addStyleSheet(import.meta.url); const maxZIndex = 2147483647; const titleHeight = 39; export class StickyTitle { constructor(title, depth) { this.dom = element("p", { className: "stickytext" }, ...title); this.setDepth(depth); } setDepth(depth) { this.dom.style.top = `${targetYPos(depth)}px`; this.dom.style.zIndex = (maxZIndex - depth).toString(); } } export function showInTree(elem, depth) { const targetTopPos = targetYPos(depth); const rect = elem.getBoundingClientRect(); if (rect.top < targetTopPos) { elem.scrollIntoView(true); window.scrollBy(0, -targetTopPos); } } function targetYPos(depth) { return titleHeight * (depth - 1); } //# sourceMappingURL=StickyTitle.js.map