* @param {!IntersectionObserverEntry} record * @private
(record)
| 77 | * @private |
| 78 | */ |
| 79 | inViewport_(record) { |
| 80 | const {boundingClientRect, isIntersecting, target} = record; |
| 81 | const {height, width} = boundingClientRect; |
| 82 | const element = /** @type {!AmpElement} */ (target); |
| 83 | |
| 84 | const show = isIntersecting && width > MIN_SIZE && height > MIN_SIZE; |
| 85 | |
| 86 | let state = this.states_.get(element); |
| 87 | const isCurrentlyShown = (state && state.shown) || false; |
| 88 | if (show === isCurrentlyShown) { |
| 89 | // Loading state is the same. |
| 90 | return; |
| 91 | } |
| 92 | |
| 93 | if (show && !state) { |
| 94 | state = this.createLoaderState_(element, width, height); |
| 95 | this.states_.set(element, state); |
| 96 | } |
| 97 | if (state) { |
| 98 | state.shown = show; |
| 99 | state.container.classList.toggle('amp-hidden', !show); |
| 100 | state.loader.classList.toggle('amp-active', show); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * @param {!AmpElement} element |
nothing calls this directly
no test coverage detected