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 895 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 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
    • mariusjopenM Offline
      mariusjopenM Offline
      mariusjopen
      Global Moderator
      wrote on last edited by
      #3

      Dear @nncrns

      ah, super good!!!

      Thank you for sharing!!

      Best!

      Marius

      www.mariusjopen.world

      1 Reply Last reply
      1
      • edgrbnzE Offline
        edgrbnzE Offline
        edgrbnz
        wrote on 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 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 last edited by Richard
            #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
            1
            • RichardR Richard

              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 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 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
                0
                • RichardR Richard

                  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 last edited by
                  #9

                  @Richard-Keith bump. 🏄‍♂️

                  1 Reply Last reply
                  0
                  • RichardR Offline
                    RichardR Offline
                    Richard
                    Global Moderator
                    wrote on 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 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
                      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
                      D
                      Double
                      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