Skip to content

Watcher support for elements not within the DOM #76

@lynchbomb

Description

@lynchbomb

Spaniel v2.4.6 does not provide support for elements being watched that are not within the DOM. Currently the ElementScheduler caches getBoundingClientRect which is set during the watch phase. Elements not yet within the DOM return default values on getBoundingClientRect which are then cached within the ElementScheduler.

watch(el: Element, callback: (frame: FrameInterface, id: string, clientRect?: ClientRect) => void, id?: string): string {
this.startTicking();
id = id || generateToken();
let clientRect = el.getBoundingClientRect();
this.queue.push({
el,
callback,
id,
clientRect
});
return id;
}

Thoughts on exposing a method within Spaniel to force a revalidation of cached getBoundingClientRect on elements being watched? Either on the Watcher or exposing the W (window proxy).

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions