File tree Expand file tree Collapse file tree 1 file changed +1
-31
lines changed
2-ui/3-event-details/8-onscroll/3-load-visible-img/source.view Expand file tree Collapse file tree 1 file changed +1
-31
lines changed Original file line number Diff line number Diff line change @@ -169,38 +169,8 @@ <h1>Нептун</h1>
169169 * Достаточно, чтобы верхний или нижний край элемента был виден
170170 */
171171 function isVisible ( elem ) {
172-
173- let coords = elem . getBoundingClientRect ( ) ;
174-
175- let windowHeight = document . documentElement . clientHeight ;
176-
177- // видны верхний ИЛИ нижний край элемента
178- let topVisible = coords . top > 0 && coords . top < windowHeight ;
179- let bottomVisible = coords . bottom < windowHeight && coords . bottom > 0 ;
180-
181- return topVisible || bottomVisible ;
182- }
183-
184- /**
185- Вариант проверки, считающий элемент видимым,
186- если он не более чем -1 страница назад или +1 страница вперед.
187-
188- function isVisible(elem) {
189-
190- let coords = elem.getBoundingClientRect();
191-
192- let windowHeight = document.documentElement.clientHeight;
193-
194- let extendedTop = -windowHeight;
195- let extendedBottom = 2 * windowHeight;
196-
197- // top visible || bottom visible
198- let topVisible = coords.top > extendedTop && coords.top < extendedBottom;
199- let bottomVisible = coords.bottom < extendedBottom && coords.bottom > extendedTop;
200-
201- return topVisible || bottomVisible;
172+ // ...ваш код...
202173 }
203- */
204174
205175 function showVisible ( ) {
206176 for ( let img of document . querySelectorAll ( 'img' ) ) {
You can’t perform that action at this time.
0 commit comments