Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • 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. Addons
  3. Project captions as cursor inside Carousel

Project captions as cursor inside Carousel

Scheduled Pinned Locked Moved Addons
11 Posts 6 Posters 843 Views
  • 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.
  • N Offline
    N Offline
    nncrns
    wrote on Mar 11, 2019, 5:12 PM last edited by
    #1

    Hi guys,

    I am fiddling with the carousel add-on to achieve the following: I want the caption of a project to appear while hovering over its thumbnail image inside a carousel. This is the website so you can get an idea: annesophieoberkrome.com/dev

    With the code of this (http://laythemeforum.com:4567/topic/1788/show-caption-as-tooltip-on-mouseover/5) article, I was able to have ALL captions follow the cursor.

    But there are two problems:

    1. The captions are underneath the carousel and even with z-index I can't get them to the front. I don't understand why. Is there something I'm missing?

    2. How can I match the caption to the thumbnail image? As far as I can see, there is no identifying ID or data attribute attached to the caption with which to achieve that.

    Or is there some better way of doing what I'm trying to do? I'd be super grateful if somebody could help me out! :) Thank you!

    1 Reply Last reply
    1
    • N Offline
      N Offline
      nncrns
      wrote on Mar 12, 2019, 10:17 AM last edited by
      #2

      Just had an idea and managed to solve it! In case anybody is looking for the same thing, this is the solution: I didn't try anymore to work with the existing captions, but rather use them as data input and display the text in a new div following my cursor. I matched the carousel slides with the captions by attaching a numbered data attribute to both of them – this works because the order of the slide elements and caption elements correspond (doesn't make a difference if the carousel has a random order or not).

      jQuery

      Before window.laytheme.on

      //Caption moves with cursor

      jQuery(document).bind('mousemove', function(e){
          jQuery(".moving-caption").offset({left: e.pageX, top: e.pageY});
      });

      window.laytheme.on("newpageshown", function(layoutObj, type, obj){

      //Attach numbered data attribute to all slides and captions

          jQuery(".lay-carousel-slide").each(function(i) {
              jQuery(this).attr("data-project","project" + (i+1));
          });

           jQuery(".single-caption").each(function(i) {
              jQuery(this).attr("data-project","project" + (i+1));
          });

      //Create element for moving caption

           jQuery("body").prepend("<p class='moving-caption _Default'></p>");

      //Insert the caption text that matches the hovered element

          jQuery(".lay-carousel-slide").hover(function(){
              var projectNumber = jQuery(this).data("project");
              var currentCaption = jQuery(".single-caption[data-project='"+projectNumber+"']").text();
              jQuery(".moving-caption").text(currentCaption);
          });
      }

      The CSS:

      .moving-caption {
          display: block;
          position: absolute;
          z-index: 10000;
      }

      Hope it helps!

      1 Reply Last reply
      1
      • M Offline
        M Offline
        mariusjopen
        Global Moderator
        wrote on Mar 13, 2019, 12:17 PM last edited by
        #3

        Dear @nncrns

        ah, super good!!!

        Thank you for sharing!!

        Best!

        Marius

        www.mariusjopen.world

        1 Reply Last reply
        1
        • E Offline
          E Offline
          edgrbnz
          wrote on Mar 15, 2019, 12:43 PM last edited by
          #4

          This is really cool stuff!
          💯× Thank you! for sharing!

          ✦ ✦ ✦

          1 Reply Last reply
          0
          • V Offline
            V Offline
            vraagje
            wrote on Aug 17, 2020, 9:28 PM last edited by
            #5

            Dear @nncrns

            This sounds so cool for the Carousel plugin!
            Only problem is that I can't get it to work when implementing the code on my own page. I copied- pasted the exact code to to my "costum CSS & HTML". And made sure my carousel images had captions.

            Can it be that the code doesn't work anymore? that I missed something, or that I have to make some slight changes? (also, I have never seen it working live since the /dev link is offline)

            Thank you!

            1 Reply Last reply
            0
            • RichardR Offline
              RichardR Offline
              Richard
              Global Moderator
              wrote on Aug 19, 2020, 4:10 PM last edited by Richard Aug 19, 2020, 12:10 PM
              #6

              Dear @vraagje

              Im taking a look into it and will let you know

              In the meantime thanks for using Lay Theme and being Awesome :)

              All the best
              Richard

              P.s @edgrbnz Is always awesome!

              V 1 Reply Last reply Aug 31, 2020, 11:12 AM
              1
              • RichardR Richard
                Aug 19, 2020, 4:10 PM

                Dear @vraagje

                Im taking a look into it and will let you know

                In the meantime thanks for using Lay Theme and being Awesome :)

                All the best
                Richard

                P.s @edgrbnz Is always awesome!

                V Offline
                V Offline
                vraagje
                wrote on Aug 31, 2020, 11:12 AM last edited by
                #7

                Dear @Richard-Keith

                Have you had time to look into this code:
                Thank you!

                @nncrns said in Project captions as cursor inside Carousel:

                Just had an idea and managed to solve it! In case anybody is looking for the same thing, this is the solution: I didn't try anymore to work with the existing captions, but rather use them as data input and display the text in a new div following my cursor. I matched the carousel slides with the captions by attaching a numbered data attribute to both of them – this works because the order of the slide elements and caption elements correspond (doesn't make a difference if the carousel has a random order or not).

                jQuery

                Before window.laytheme.on

                //Caption moves with cursor

                jQuery(document).bind('mousemove', function(e){
                    jQuery(".moving-caption").offset({left: e.pageX, top: e.pageY});
                });

                window.laytheme.on("newpageshown", function(layoutObj, type, obj){

                //Attach numbered data attribute to all slides and captions

                    jQuery(".lay-carousel-slide").each(function(i) {
                        jQuery(this).attr("data-project","project" + (i+1));
                    });

                     jQuery(".single-caption").each(function(i) {
                        jQuery(this).attr("data-project","project" + (i+1));
                    });

                //Create element for moving caption

                     jQuery("body").prepend("<p class='moving-caption _Default'></p>");

                //Insert the caption text that matches the hovered element

                    jQuery(".lay-carousel-slide").hover(function(){
                        var projectNumber = jQuery(this).data("project");
                        var currentCaption = jQuery(".single-caption[data-project='"+projectNumber+"']").text();
                        jQuery(".moving-caption").text(currentCaption);
                    });
                }

                The CSS:

                .moving-caption {
                    display: block;
                    position: absolute;
                    z-index: 10000;
                }

                1 Reply Last reply
                0
                • RichardR Offline
                  RichardR Offline
                  Richard
                  Global Moderator
                  wrote on Sep 4, 2020, 5:02 PM last edited by
                  #8

                  Dear @vraagje

                  I will take a look into soon and get back to you, apologies for the late reply, forgive me,

                  Let me know if you have any other questions as well and we can come to a solution! :)

                  Best wishes & a great weekend

                  Richard

                  V 1 Reply Last reply Oct 25, 2020, 7:28 PM
                  0
                  • RichardR Richard
                    Sep 4, 2020, 5:02 PM

                    Dear @vraagje

                    I will take a look into soon and get back to you, apologies for the late reply, forgive me,

                    Let me know if you have any other questions as well and we can come to a solution! :)

                    Best wishes & a great weekend

                    Richard

                    V Offline
                    V Offline
                    vraagje
                    wrote on Oct 25, 2020, 7:28 PM last edited by
                    #9

                    @Richard-Keith bump. 🏄‍♂️

                    1 Reply Last reply
                    0
                    • RichardR Offline
                      RichardR Offline
                      Richard
                      Global Moderator
                      wrote on Oct 29, 2020, 10:47 AM last edited by
                      #10

                      Dear @vraagje

                      Im so sorry!!,
                      Could you post a link to your website with the carousel in question and i will have a better idea concept of implementing it to your page and trying to get it to function :)

                      let me know and once again deepest apologies for my terrible reply!

                      Best
                      Richard

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        Gon
                        wrote on Dec 22, 2021, 11:59 PM last edited by
                        #11

                        Hey!

                        I'm trying to figure out how can i use this code to show the number of the image instead of the caption when hovering over it, but since I'm a total programming noob I had not been able to get it yet.

                        Could you please help me out?

                        Thanks in advance,

                        Best
                        Gonzalo.

                        1 Reply Last reply
                        0
                        • S spiralglue referenced this topic on Jan 10, 2024, 8:01 PM
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        I also code custom websites or custom Lay features.
                        💿 Email me here: 💿
                        info@laytheme.com

                        Before you post:
                        1. When using a WordPress Cache plugin, disable it or clear your cache.
                        2. Update Lay Theme and all Lay Theme Addons
                        3. Disable all Plugins
                        4. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"

                        This often solves issues you might run into

                        When you post:
                        1. Post a link to where the problem is
                        2. Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
                        3. If the problem is difficult to explain, post screenshots / link to a video to explain it
                        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