diff options
author | 2024-08-05 14:29:20 +0300 | |
---|---|---|
committer | 2024-08-05 13:29:20 +0200 | |
commit | 196092ae69eb1249206846ddfc162049b03f42b4 (patch) | |
tree | 406a5c91bfd0459c4dcf78ba1d6050fb19548e53 /examples/blog/src | |
parent | da86d5459f66c45b87a97f3aab384454a38ea279 (diff) | |
download | astro-196092ae69eb1249206846ddfc162049b03f42b4.tar.gz astro-196092ae69eb1249206846ddfc162049b03f42b4.tar.zst astro-196092ae69eb1249206846ddfc162049b03f42b4.zip |
fix: audit incorrectly flagging images as above the fold (#10891) (#11617)
* fix: audit incorrectly flagging images as above the fold (#10891)
Previously used lement.offsetTop to find the y position of the image, which does not work when the element parent has a position: relative property.
Instead, this uses lement.getBoundingClientRect().y top get real y position of the image.
There's one issue though, which is that getBoundingClientRect returns the position relative to the user's viewport, not the absolute position.
So, add window.scrollY to the value to cancel that effect out, and you have the element's absolute position.
https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect
https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY
* chore: add changeset
Diffstat (limited to 'examples/blog/src')
0 files changed, 0 insertions, 0 deletions