logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

get_rect_from_entry.js (817B)


  1. // Get the bounding client rect from an IntersectionObserver entry.
  2. // This is to work around a bug in Chrome: https://crbug.com/737228
  3. let hasBoundingRectBug;
  4. function getRectFromEntry(entry) {
  5. if (typeof hasBoundingRectBug !== 'boolean') {
  6. const boundingRect = entry.target.getBoundingClientRect();
  7. const observerRect = entry.boundingClientRect;
  8. hasBoundingRectBug = boundingRect.height !== observerRect.height ||
  9. boundingRect.top !== observerRect.top ||
  10. boundingRect.width !== observerRect.width ||
  11. boundingRect.bottom !== observerRect.bottom ||
  12. boundingRect.left !== observerRect.left ||
  13. boundingRect.right !== observerRect.right;
  14. }
  15. return hasBoundingRectBug ? entry.target.getBoundingClientRect() : entry.boundingClientRect;
  16. }
  17. export default getRectFromEntry;