bottomImgs.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // images collées en bas de page
  2. if (debug) console.log('start bottomImgs');
  3. (function() {
  4. let bottomImgs = document.querySelectorAll('.bottomimg, .tripleimgs_bottom, .tripleimgs2_bottom');
  5. for (let bottomImg of bottomImgs) {
  6. let pageBottom = bottomImg.closest('.pagedjs_area').getBoundingClientRect().bottom;
  7. let imgBottomPos = pageBottom - bottomImg.lastElementChild.getBoundingClientRect().bottom;
  8. bottomImg.style.transform = `translateY(${imgBottomPos}px)`;
  9. }
  10. // pour les images en bas dans les pages avec du texte
  11. let bottomVignettes = document.querySelectorAll('.imgsmall_bottom');
  12. for (let bottomVignette of bottomVignettes) {
  13. let pageBottom = bottomVignette.closest('.pagedjs_area').getBoundingClientRect().bottom;
  14. let vignetteSize = bottomVignette.getBoundingClientRect().height;
  15. if (bottomVignette.previousElementSibling) {
  16. let textBottom = bottomVignette.previousElementSibling.getBoundingClientRect().bottom;
  17. if (bottomVignette.previousElementSibling.classList.contains('labeur') ||
  18. bottomVignette.previousElementSibling.classList.contains('citation') ||
  19. bottomVignette.previousElementSibling.classList.contains('free') ||
  20. bottomVignette.previousElementSibling.classList.contains('temps')) {
  21. bottomVignette.style.marginTop = `${(pageBottom - textBottom) - vignetteSize}px`;
  22. }
  23. bottomVignette.style.transform = 'translateY(12px)';
  24. } else {
  25. let vignetteBottom = bottomVignette.getBoundingClientRect().bottom;
  26. bottomVignette.style.transform = `translateY(${pageBottom - vignetteBottom}px)`;
  27. }
  28. }
  29. })();
  30. if (debug) console.log('end bottomImgs');