UNPKG

db-lgtv-focus-engine

Version:

the Best TV focus engine

29 lines (28 loc) 1.07 kB
export function bindHashListener(focus_engine) { window.onhashchange = function (event) { let callback = () => { if (!focus_engine.options.ROUTER_CACHE) delete(focus_engine.focused_map[window.location.href]) window.cancelAnimationFrame(focus_engine.animation_id) window.$engine.is_smooth_scrolling = false let leaf = focus_engine.findFocusedLeaf() if (!leaf || !leaf.el) return if (leaf.block !== 'none' && leaf.inline !== 'none') { setTimeout(() => { leaf.el.scrollIntoView({ behavior: 'instant', block: leaf.block || "center", inline: leaf.inline || "center", msg: '瞬移初始化焦点位置' }) }) } } window.$engine.$nextTick(() => { callback() }) callback() } } export function unbindHashListener(focus_engine) { window.onhashchange = (e) => {} }