@@ -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
186174function 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
826818export default utils ;
0 commit comments