(elements: SplitTextTarget, config: SplitTextConfig)
| 315 | _split: () => void; |
| 316 | |
| 317 | constructor(elements: SplitTextTarget, config: SplitTextConfig) { |
| 318 | _initIfNecessary(); |
| 319 | this.elements = _elements(elements); |
| 320 | this.chars = []; |
| 321 | this.words = []; |
| 322 | this.lines = []; |
| 323 | this.masks = []; |
| 324 | this.vars = config; |
| 325 | this.elements.forEach((el: HTMLElement) => { // avoid re-splitting the same element multiple times |
| 326 | config.overwrite !== false && (el as any)[_splitProp]?._data.orig.filter(({element}: SplitTextOriginal) => element === el).forEach(_revertOriginal); |
| 327 | (el as any)[_splitProp] = this; // set the split prop to the current instance |
| 328 | }); |
| 329 | this._split = () => this.isSplit && this.split(this.vars); |
| 330 | let orig: SplitTextOriginal[] = [], |
| 331 | timerId: number, |
| 332 | checkWidths = () => { |
| 333 | let i: number = orig.length, |
| 334 | o: SplitTextOriginal; |
| 335 | while (i--) { |
| 336 | o = orig[i]; |
| 337 | let w: number = (o.element as HTMLElement).offsetWidth; |
| 338 | if (w !== o.width) { |
| 339 | o.width = w; |
| 340 | this._split(); |
| 341 | return; |
| 342 | } |
| 343 | } |
| 344 | }; |
| 345 | this._data = {orig: orig, obs: typeof(ResizeObserver) !== "undefined" && new ResizeObserver(() => { clearTimeout(timerId); timerId = setTimeout(checkWidths, 200) as unknown as number})}; |
| 346 | |
| 347 | _context(this); |
| 348 | this.split(config); |
| 349 | } |
| 350 | |
| 351 | split(config: SplitTextConfig) { |
| 352 | (this._ctx || _defaultContext).add(() => { |
nothing calls this directly
no test coverage detected