We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
isElementInView
1 parent a080a38 commit f18fadaCopy full SHA for f18fada
__tests__/isElementInView.test.js
@@ -0,0 +1,24 @@
1
+import isElementInView from 'utils/isElementInView.js';
2
+
3
+const element1 = {
4
+ attributes: {
5
+ top: 0,
6
+ bottom: 500,
7
+ },
8
+};
9
10
+const element2 = {
11
12
+ top: 2500,
13
+ bottom: 4000,
14
15
16
17
+const windowHeight = 1000;
18
19
+test('Returns whether an element is in view', () => {
20
+ expect(isElementInView(element1, windowHeight, 1500)).toBe(false);
21
+ expect(isElementInView(element1, windowHeight, 0)).toBe(true);
22
+ expect(isElementInView(element2, 4000, 0)).toBe(true);
23
+ expect(isElementInView(element2, windowHeight, 6500)).toBe(false);
24
+});
0 commit comments