Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. General Discussion
  3. Image hover addon with video possible?

Image hover addon with video possible?

Scheduled Pinned Locked Moved General Discussion
5 Posts 3 Posters 597 Views 2 Watching
  • 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
    V
    Verena
    wrote on last edited by
    #1

    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
    0
    • arminunruhA
      arminunruhA
      arminunruh
      Global Moderator
      wrote on last edited by
      #2

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

      1 Reply Last reply
      1
      • V
        V
        Verena
        wrote on last edited by
        #3

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

        1 Reply Last reply
        1
        • M
          M
          melo_lenosier
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • M
            M
            melo_lenosier
            wrote on last edited by
            #5

            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
            1

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            Online Users
            Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
            laytheme.com
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Recent
            • Tags
            • Popular
            • Users
            • Search