Skip to content

Commit ec478a3

Browse files
authored
Merge pull request #1 from ThinkDeepTech/hm/impl
Hm/impl
2 parents 5b7d500 + 3db2800 commit ec478a3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

deep-element-behavior.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
<script>
22
window.deep = window.deep || {};
33

4+
// TODO: JSDoc
45
ElementBehaviorImpl = {
56
properties: {
67
/* True if the element is visible to the user. False otherwise. */
7-
isVisible: {
8+
isVisibleToUser: {
89
type: Boolean,
910
value: false
1011
},
1112
/* Observer monitoring resize events */
1213
__resizeObserver: Object
1314
},
1415
attached() {
15-
this.__resizeObserver = new ResizeObserver(this.__updateVisibility);
16+
this.__resizeObserver = new ResizeObserver(this.__updateVisibility.bind(this));
1617
this.__resizeObserver.observe(this);
1718
},
1819
detached() {
19-
20+
this.__resizeObserver.disconnect();
2021
},
2122
__updateVisibility(resizeEntries) {
2223
if(!Array.isArray(resizeEntries) || !resizeEntries.length) return;
2324
const boundingRectangle = resizeEntries[0].contentRect;
2425
const {height, width} = boundingRectangle;
25-
this.set('isVisible', Boolean(height) || Boolean(width));
26+
this.set('isVisibleToUser', Boolean(height) || Boolean(width));
2627
}
2728
};
2829
deep.ElementBehavior = [ElementBehaviorImpl];

0 commit comments

Comments
 (0)