Lay Theme Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Search

    Image hover addon with video possible?

    General Discussion
    3
    5
    43
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • V
      Verena last edited by

      I’d like to insert a video instead of image as hover. Is this possible? Gifs are juste too low in quality.

      1 Reply Last reply Reply Quote 0
      • arminunruh
        arminunruh Global Moderator last edited by

        ahh no its not possible :O
        but a good idea, i will write it down

        1 Reply Last reply Reply Quote 1
        • V
          Verena last edited by

          Would be nice to have in the future. Tanks a lot! :)

          1 Reply Last reply Reply Quote 1
          • M
            melo_lenosier last edited by

            I am also very interested in this. Video-hover would be great.
            Thank you!

            1 Reply Last reply Reply Quote 0
            • M
              melo_lenosier last edited by

              If anybody needs it, here is the script I used.
              It was tricky because there was an annoying phenomena between the hover and the scroll functions. Basically while scrolling the page, the browser (Chrome especially) doesn't send any other mouse coordinates, therefore the hovered video was constantly there till the scroll was stopped.

              Here is a script that avoid this problem:

              <script>
              let hoveredElement;
              let mouseX = 0, mouseY = 0;
              
              document.addEventListener('DOMContentLoaded', () => {
                document.addEventListener('mousemove', event => {
                  mouseX = event.clientX;
                  mouseY = event.clientY;
              
                  hover(event.target);
                });
              
                document.addEventListener('scroll', () => {
                  const hoverTarget = document.elementFromPoint(mouseX, mouseY);
                  if (hoverTarget) {
                    hover(hoverTarget);
                  }
                });
              });
              
              function hover(targetElement) {
                // If the target and stored element are the same, return early
                // because setting it again is unnecessary.
                if (hoveredElement === targetElement) {
                  return;
                }
              // On first run, `hoveredElement` is undefined.
                if (hoveredElement) {
                  if (hoveredElement.hasAttribute("data-videoid")) {
              document.getElementById(hoveredElement.getAttribute("data-videoid")).classList.remove('hoverscrolled');
                   console.log(hoveredElement.getAttribute("data-videoid"));
                   console.log(document.getElementById(hoveredElement.getAttribute("data-videoid")));
              
              }
              
                }
              
                hoveredElement = targetElement;
              if (hoveredElement.hasAttribute("data-videoid")) {
              document.getElementById(hoveredElement.getAttribute("data-videoid")).classList.add('hoverscrolled');
                    console.log(hoveredElement.getAttribute("data-videoid"));
                   console.log(document.getElementById(hoveredElement.getAttribute("data-videoid")));
              }
              
              }
              </script>
              

              HTML:

              <div data-videoid="one_data"  >
              </div>
              
              <video id="one_data" class="vid_background" autoplay muted loop>
                <source src="https://somevideo.mp4" type="video/mp4">  Your browser does not support HTML5 video.
              </video>
              
              

              CSS:

              video.vid_background{
                   opacity: 0;
                   left: 50%;
                  top: 50%;
                  transform: translate(-50%, -50%);
                  z-index: -5;
                  width: 40%;
                  position: fixed;
                  height: 50%;
                  -webkit-transition: none;
                  -o-transition: none;
                  transition: none;
               }
               
              video.vid_background.hoverscrolled  {
                  opacity: 1;
                  left: 50%;
                  top: 50%;
                  transform: translate(-50%, -50%);
                  z-index: -5;
                  width: 40%;
                  position: fixed;
                  height: 50%; 
                  -webkit-transition: none;
                  -o-transition: none;
                  transition: none;
               }
              
              1 Reply Last reply Reply Quote 1
              • First post
                Last post

              Before you post

              Use the Search Feature. Maybe there is already a solution to your issue.

              1. Update Lay Theme and all Lay Theme Addons
              2. Disable all Plugins
              3. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code ", click "Save Changes"
              4. Now see if your problem solved itself
              5. Go here, see if your problem is listed here:
              Troubleshooting

              When you post:
              1. Post a link to where the problem is
              2. If the problem is difficult to explain, post screenshots / link to a video to explain it

              Thanks!

              Online Users

              Recent Topics

              • T

                OpenType Feature

              • T

                Split Screen just on front page / subpages without the split?

              • T

                problem when I click on the category filter buttons on mobile

              • G

                z index has different behaviors on different pages

              laytheme.com