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. carousel captions following cursor

carousel captions following cursor

Scheduled Pinned Locked Moved General Discussion
5 Posts 2 Posters 759 Views 1 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.
  • S
    S
    spiralglue
    wrote on last edited by spiralglue
    #1

    hello! i'm curious if anyone can help out with a line up code i'm sitting on.

    i found this super helpful thread from a few years ago that documented having carousel slide captions follow the cursor as you hover over the carousel area. link

    the only noticeable issue in this code is when the carousel autoplays, or the user clicks towards the prev/next slide without moving their cursor. the moving caption will not update its text to match the current slide until the cursor moves, due to the nature of the jQuery / function. i have it pasted below for reference. does anyone know what line of code can be adjusted here, so the currentCaption variable is also updated whenever the .is-selected carousel slide changes in the document? and not only when the mouse moves. link to the site - carousel / effect in 1st section

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

    thank you to anyone looking!

    1 Reply Last reply
    0
    • arminunruhA
      arminunruhA
      arminunruh
      Global Moderator
      wrote on last edited by
      #2
      jQuery(".lay-carousel-slide").on('hover mouseup', function(){
                  var projectNumber = jQuery(".is-selected").data("project");
                  var currentCaption = jQuery(".single-caption[data-project='"+projectNumber+"']").text();
                  jQuery(".moving-caption").text(`● ${currentCaption}`);
              });
      

      adding mouseup might solve this

      does that work?

      if not, does this work?:

      jQuery(".lay-carousel-slide").on('hover mouseup', function(){
      setTimeout(function(){
                  var projectNumber = jQuery(".is-selected").data("project");
                  var currentCaption = jQuery(".single-caption[data-project='"+projectNumber+"']").text();
                  jQuery(".moving-caption").text(`● ${currentCaption}`);
      }, 0);
              });
      
      1 Reply Last reply
      1
      • S
        S
        spiralglue
        wrote on last edited by
        #3

        thank you armin.

        i switched out 'hover' for 'mouseover' in your code, .on('hover') was buggy because the API for it was deprecated i think? 'mouseup' did the trick for when manually switching between slides with mouse clicks! unfortunately, my main issue here is how to listen for when the carousel autoplay advances to the next slide, since this is independent from mouse events. when you wait for the autoplay to switch slides, the caption still stays with the previous slide, until the mouse is moved.

        1 Reply Last reply
        0
        • arminunruhA
          arminunruhA
          arminunruh
          Global Moderator
          wrote on last edited by
          #4
          <script>
          
          window.laytheme.on("newpageshown", function(){
              setTimeout(function(){
                  jQuery(".lay-carousel-wrap").each(function(){
                      var $carousel = jQuery(this);
                      (function($carousel){
                          var myswiper = $carousel.data('myswiper');
                          if(myswiper) {
                              myswiper.on('slideChangeTransitionEnd', function () {
                                console.log('slide changed');
                                // var ix = myswiper.activeIndex;
                                var $activeSlide = $carousel.find('.is-selected');
                                console.log($activeSlide)
          // do your thing
                              });
                          }
                      })($carousel);
                  })
              }, 2000)
          });
          
          </script>
          
          1 Reply Last reply
          0
          • arminunruhA
            arminunruhA
            arminunruh
            Global Moderator
            wrote on last edited by
            #5

            maybe other events will be better for u / good reads:

            https://swiperjs.com/swiper-api#events

            https://stackoverflow.com/questions/32945099/how-to-detect-current-slide-in-swiper-js

            https://stackoverflow.com/questions/592396/what-is-the-purpose-of-a-self-executing-function-in-javascript

            1 Reply Last reply
            0

            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
            I
            itsbadjujuju
            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