Test migration to jest by hand
Apparently using regular expressions is way easier.
This commit is contained in:
@ -0,0 +1,9 @@
|
||||
const elementIsVisibleInViewport = (el, partiallyVisible = false) => {
|
||||
const { top, left, bottom, right } = el.getBoundingClientRect();
|
||||
const { innerHeight, innerWidth } = window;
|
||||
return partiallyVisible
|
||||
? ((top > 0 && top < innerHeight) || (bottom > 0 && bottom < innerHeight)) &&
|
||||
((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth))
|
||||
: top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth;
|
||||
};
|
||||
module.exports = elementIsVisibleInViewport;
|
||||
@ -0,0 +1,10 @@
|
||||
const expect = require('expect');
|
||||
const elementIsVisibleInViewport = require('./elementIsVisibleInViewport.js');
|
||||
|
||||
|
||||
test('elementIsVisibleInViewport is a Function', () => {
|
||||
expect(elementIsVisibleInViewport).toBeInstanceOf(Function);
|
||||
});
|
||||
t.pass('Tested on 09/02/2018 by @chalarangelo');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user