UNPKG

@bookbox/view-html

Version:

Bookbox view for html

26 lines (25 loc) 908 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.gotoKey = gotoKey; const navigation_1 = require("./navigation"); const actions = { push: navigation_1.pushHistory, replace: navigation_1.replaceHistory, }; const className = "book-box_highlight"; function goto(selector, options) { const node = document.querySelector(selector); if (!node) return; const { useHistory = false, url } = options !== null && options !== void 0 ? options : {}; node.scrollIntoView(); if (useHistory && url) { const method = typeof useHistory === "string" ? useHistory : "replace"; actions[method](url); } node.classList.add(className); setTimeout(() => (node ? node.classList.remove(className) : undefined), 1000); } function gotoKey(key, options) { goto(`.book-box_content *[data-layout='top'][data-key='${key}']`, options); }