UNPKG

web-barrier-free

Version:

[![LICENSE](https://img.shields.io/github/license/bubkoo/html-to-image?style=flat-square)](./LICENSE) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/karma-runner/karma-cover

37 lines (33 loc) 1.18 kB
import Wbf from './index' import { getElText, getNotContainChildText, showBarDomId } from './util' const overHandler = ( e: { target: HTMLElement }, wbf: Wbf ): void => { const notContainChildText = getNotContainChildText(e.target) if (notContainChildText.length === 0) return if (e.target !== document.body && e.target.tagName.toLowerCase() !== 'html' && e.target.id !== showBarDomId) { wbf.emphasize(e.target) const text = getElText(e.target, wbf.language) wbf.readMode === 'finger' && wbf.playAudio(text) if (wbf.showBarEl != null) { if (text.length > 150) { wbf.showBarEl.style.fontSize = '24px' } else if (text.length > 100) { wbf.showBarEl.style.fontSize = '26px' } else if (text.length > 50) { wbf.showBarEl.style.fontSize = '28px' } else if (text.length > 20) { wbf.showBarEl.style.fontSize = '30px' } else { wbf.showBarEl.style.fontSize = '32px' } wbf.showBarEl.innerText = text } } } const outHandler = (e: { target: HTMLElement }, wbf): void => { wbf.removeEmphasize(e.target) } export { overHandler, outHandler }