forked from hyoo-ru/mam_mol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeter.view.ts
68 lines (56 loc) · 1.15 KB
/
meter.view.ts
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
namespace $.$$ {
export class $mol_meter extends $.$mol_meter {
@ $mol_mem
rect() {
const node = this.dom_node()
const win = this.$.$mol_dom_context
if( node !== $mol_dom_context.document.body ) {
new $mol_after_frame( $mol_atom2.current!.fresh )
try {
const { left , top , right , bottom , width , height } = node.getBoundingClientRect()
return { left , top , right , bottom , width , height , zoom : win.devicePixelRatio || 1 }
} catch( error ) {
// IE11
}
}
const size = $mol_window.size()
return {
zoom : win.devicePixelRatio || 1 ,
left : 0 ,
top : 0 ,
right : size.width ,
bottom : size.height ,
width : size.width ,
height : size.height ,
}
}
@ $mol_mem
top() {
return this.rect().top
}
@ $mol_mem
bottom() {
return this.rect().bottom
}
@ $mol_mem
left() {
return this.rect().left
}
@ $mol_mem
right() {
return this.rect().right
}
@ $mol_mem
width() {
return this.rect().width
}
@ $mol_mem
height() {
return this.rect().height
}
@ $mol_mem
zoom() {
return this.rect().zoom
}
}
}