-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.dart
34 lines (27 loc) · 1.03 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import 'dart:html';
import 'dart:async';
import 'package:resize_observer/resize_observer.dart' as ro;
bool observing = true;
Future<void> main() async {
final textarea = document.getElementById('textarea')!;
final obsEl = document.getElementById('observing')!;
ro.ResizeObserver.observe(textarea, _onResize);
obsEl.innerHtml = observing.toString();
document.getElementById('supported')!.innerHtml =
ro.ResizeObserver.supported.toString();
document.getElementById('observeBtn')!.onClick.listen((_) {
ro.ResizeObserver.observe(textarea, _onResize);
observing = true;
obsEl.innerHtml = observing.toString();
});
document.getElementById('unobserveBtn')!.onClick.listen((_) {
ro.ResizeObserver.unobserve(textarea);
observing = false;
obsEl.innerHtml = observing.toString();
});
}
void _onResize(Element el, num x, num y, num width, num height, num top,
num bottom, num left, num right) {
el.text =
'x: $x y: $y width: $width height: $height top: $top left: $left bottom: $bottom right: $right';
}