Skip to content

Commit 32a6e07

Browse files
committed
Check if cell requires repaint using top/bottom only, and trigger when cell is partially in view
1 parent 8dab378 commit 32a6e07

File tree

1 file changed

+4
-8
lines changed
  • addon/components/collection-scroll-view/collection-items

1 file changed

+4
-8
lines changed

addon/components/collection-scroll-view/collection-items/index.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@ import Component from '@glimmer/component';
55
import identity from 'ember-collection/utils/identity';
66
import { tracked } from '@glimmer/tracking';
77
import { reads } from 'macro-decorators';
8-
import { schedule } from '@ember/runloop';
98

109
function isElementInViewport (el) {
11-
var rect = el.getBoundingClientRect();
12-
return (
13-
rect.top >= 0 &&
14-
rect.left >= 0 &&
15-
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
16-
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
17-
);
10+
let rect = el.getBoundingClientRect();
11+
let windowHeight = (window.innerHeight || document.documentElement.clientHeight);
12+
return (rect.top > 0 && rect.top < windowHeight) ||
13+
(rect.bottom > 0 && rect.bottom < windowHeight);
1814
}
1915

2016
let scrollViewCollectionItemsCellCounter = 0;

0 commit comments

Comments
 (0)