Skip to content

Commit a9b5035

Browse files
committed
maint(core utils): Deprecate elementInViewport in favor of isElementInViewport.
1 parent fa2a703 commit a9b5035

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/core/utils.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,6 @@ function findLabel(input) {
170170
}
171171
}
172172

173-
// Taken from http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport
174-
function elementInViewport(el) {
175-
var rect = el.getBoundingClientRect(),
176-
docEl = document.documentElement,
177-
vWidth = window.innerWidth || docEl.clientWidth,
178-
vHeight = window.innerHeight || docEl.clientHeight;
179-
180-
if (rect.right < 0 || rect.bottom < 0 || rect.left > vWidth || rect.top > vHeight)
181-
return false;
182-
return true;
183-
}
184-
185173
// Taken from http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
186174
function escapeRegExp(str) {
187175
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
@@ -792,7 +780,6 @@ var utils = {
792780
isObject: isObject,
793781
extend: extend,
794782
findLabel: findLabel,
795-
elementInViewport: elementInViewport,
796783
removeWildcardClass: removeWildcardClass,
797784
hideOrShow: hideOrShow,
798785
addURLQueryParameter: addURLQueryParameter,
@@ -821,6 +808,11 @@ var utils = {
821808
threshold_list: threshold_list,
822809
is_option_truthy: is_option_truthy,
823810
getCSSValue: dom.get_css_value, // BBB: moved to dom. TODO: Remove in upcoming version.
811+
elementInViewport: (el) => {
812+
// BBB: Remove with next major version.
813+
console.warn("Deprecated. Use utils.isElementInViewport");
814+
return isElementInViewport(el);
815+
},
824816
};
825817

826818
export default utils;

0 commit comments

Comments
 (0)