Commit 451a0931 authored by Constance Okoghenun's avatar Constance Okoghenun

Removed float values from isInViewport compuation

This ensures it will always return the right value when an element is
less than 1px offscreen.
parent 43805024
...@@ -130,7 +130,7 @@ export const isInViewport = (el, offset = {}) => { ...@@ -130,7 +130,7 @@ export const isInViewport = (el, offset = {}) => {
rect.top >= (top || 0) && rect.top >= (top || 0) &&
rect.left >= (left || 0) && rect.left >= (left || 0) &&
rect.bottom <= window.innerHeight && rect.bottom <= window.innerHeight &&
rect.right <= window.innerWidth parseInt(rect.right, 10) <= window.innerWidth
); );
}; };
......
---
title: Resolve Cannot scroll forwards in time for roadmap view
merge_request: 9530
author:
type: fixed
...@@ -855,6 +855,7 @@ describe('common_utils', () => { ...@@ -855,6 +855,7 @@ describe('common_utils', () => {
}); });
it('returns true when provided `el` is in viewport', () => { it('returns true when provided `el` is in viewport', () => {
el.setAttribute('style', `position: absolute; right: ${window.innerWidth + 0.2};`);
document.body.appendChild(el); document.body.appendChild(el);
expect(commonUtils.isInViewport(el)).toBe(true); expect(commonUtils.isInViewport(el)).toBe(true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment