79436916

Date: 2025-02-13 15:50:20
Score: 2
Natty:
Report link

A solution of the capture with scroll issue by @songxingguo

height: fit-content

A code snippet that works for me:

const capture = () => {
  const node = document.getElementById('timeline-list');
  const currentHeight = node.style.height;
  node.style.height = 'fit-content';
  html2canvas(node)
    .then(function (canvas) {
      const imgData = canvas.toDataURL('image/png');
      const link = document.createElement('a');
      link.href = imgData;
      link.download = 'captured-image.png';
      link.click();
    })
    .finally(() => {
      node.style.height = currentHeight;
    });
};

Can I use "fit-content"? supported browser list

Reasons:
  • Whitelisted phrase (-1): works for me
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (1):
Posted by: renzhexigua