File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,11 +38,12 @@ Fluid.utils = {
3838 elementVisible : function ( element , offsetFactor ) {
3939 offsetFactor = offsetFactor && offsetFactor >= 0 ? offsetFactor : 0 ;
4040 var rect = element . getBoundingClientRect ( ) ;
41- const viewportHeight = window . innerHeight || document . documentElement . clientHeight ;
42- return (
43- ( rect . top >= 0 && rect . top <= viewportHeight * ( 1 + offsetFactor ) + rect . height / 2 ) ||
44- ( rect . bottom >= 0 && rect . bottom <= viewportHeight * ( 1 + offsetFactor ) + rect . height / 2 )
45- ) ;
41+ const viewportHeight = ( window . innerHeight || document . documentElement . clientHeight ) * ( 1 + offsetFactor ) ;
42+ const viewportWidth = ( window . innerWidth || document . documentElement . clientWidth ) * ( 1 + offsetFactor ) ;
43+
44+ // 判断元素的顶部、底部、左侧或右侧是否在视口内
45+ // 如果有一个在视口内,则认为元素可见
46+ return rect . top < viewportHeight || rect . bottom > 0 || rect . left < viewportWidth || rect . right > 0 ;
4647 } ,
4748
4849 waitElementVisible : function ( selectorOrElement , callback , offsetFactor ) {
You can’t perform that action at this time.
0 commit comments