atomiks / tippyjs

Tooltip, popover, dropdown, and menu library
https://atomiks.github.io/tippyjs/
MIT License
11.86k stars 520 forks source link

Videos don't autoplay #1089

Closed johangiraud closed 1 year ago

johangiraud commented 1 year ago

Discussed in https://github.com/atomiks/tippyjs/discussions/1088

Originally posted by **johangiraud** October 10, 2022 I added a `
johangiraud commented 1 year ago

Here is the solution 😃:

const modal = document.querySelector('.modal'),
  modalContent = modal.innerHTML;

tippy('.card', {
  content: modalContent,
  allowHTML: true,
  interactive: true,
  animation: 'shift-away',
  followCursor: true,
  arrow: false,
  onShow(instance) {
    setTimeout(() => {
      let video = instance.popper.getElementsByTagName('video')[0];
      video.currentTime = 0; //start from begining
      video.play();
    }, 1);

  },
});

Thanks to this answer