File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 128128 show ( e . target . parentNode . parentNode ) ;
129129 }
130130 } ;
131+ function isElementVisible ( el ) {
132+ const rect = el . getBoundingClientRect ( ) ;
133+ return rect . top < window . innerHeight && rect . top > 0 && rect . bottom >= 0 ;
134+ }
131135 function findFirstVisibleElement ( selector ) {
132136 const elements = document . querySelectorAll ( selector ) ;
133137 const firstVisibleElement = Array . from ( elements ) . find ( el => {
134- const rect = el . getBoundingClientRect ( ) ;
135- return rect . top < window . innerHeight && rect . top > 0 && rect . bottom >= 0 ;
138+ return isElementVisible ( el ) ;
136139 } ) ;
137140 return firstVisibleElement ;
138141 }
141144 clearTimeout ( checkTimer ) ;
142145 if ( e . target == downloadBtn ) return ;
143146 checkTimer = setTimeout ( ( ) => {
147+ if ( isElementVisible ( downloadBtn ) ) return ;
144148 let target = findFirstVisibleElement ( "[data-testid='card.layoutLarge.media']" ) ;
145149 if ( target ) {
146150 return show ( target . parentNode ) ;
You can’t perform that action at this time.
0 commit comments