measureSize method
An implementation of the typedef interface AsyncMeasureSize.
Returns a stream of size and position information on pane
. If track
is true, then listens for likely DOM reflows via DomService and dirty
checks for updates, only firing an event on the stream if either the
size or position has changed since the last event.
If sync
is true, then the size/position information is read
synchronously and not part of the read/write queue. This helps performance
but should only be used on elements that will not effect layout much such
as overlays/popups.
Implementation
Stream<Rectangle> measureSize(HtmlElement pane,
{bool track = false, bool sync = false}) {
if (track) {
return _domRuler.track(pane);
} else {
// TODO(google): It should be an actual stream that is updated whenever
// the portal is changed, right?
if (!sync) {
return _domRuler.measure(pane).asStream();
}
return Stream.fromIterable([_domRuler.measureSync(pane)]);
}
}