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. General Discussion
  3. Dot cursor using Vanilla.js issue with carousel

Dot cursor using Vanilla.js issue with carousel

Scheduled Pinned Locked Moved General Discussion
8 Posts 3 Posters 258 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.
  • B Offline
    B Offline
    Baptiste
    wrote on Feb 22, 2021, 10:03 AM last edited by Baptiste Mar 8, 2021, 5:39 PM
    #1

    Hello Laypeople, Layteam, @arminunruh and @Richard-K

    Working on a custom dot cursor using vanillaJS. It works on my page https://baptisteperon.com except on the carousel where I would like to have the same animation as I have on my codepen : https://codepen.io/B02P16/pen/LYbjMYo

    If someone have an idea of what I'm doing wrong it would be nice, thanks.

    Best,
    Baptiste

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Richard
      Global Moderator
      wrote on Feb 23, 2021, 1:36 AM last edited by
      #2

      Dear @Baptiste

      Hey! thats really cool & the website looks great :)
      It functions within the carousel for me?

      Best wishes & a wonderful day

      Richard

      B 1 Reply Last reply Feb 23, 2021, 8:13 AM
      0
      • R Richard
        Feb 23, 2021, 1:36 AM

        Dear @Baptiste

        Hey! thats really cool & the website looks great :)
        It functions within the carousel for me?

        Best wishes & a wonderful day

        Richard

        B Offline
        B Offline
        Baptiste
        wrote on Feb 23, 2021, 8:13 AM last edited by
        #3

        Hey @Richard-K,

        The two dots (black-blue) works but not the left/right cursor I would like to have.
        If you compare my codepen and my website here a difference :

        The cursors should be like that:

        Normal cursor :
        Capture d’écran 2021-02-23 à 09.08.20.png

        Right cursor on carousel :
        Capture d’écran 2021-02-23 à 09.08.32.png

        Left cursor on carousel :
        Capture d’écran 2021-02-23 à 09.08.41.png

        It works on the codepen, not on Lay, any idea why?

        Best.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Richard
          Global Moderator
          wrote on Feb 27, 2021, 1:08 AM last edited by
          #4

          Dear @Baptiste

          On the codepen example you have the left & right <div>'s

          <div class="col">
            <div class="lay-carousel cursor-left">LEFT</div>
          </div>
          
          <div class="col">
            <div class="lay-carousel cursor-right">RIGHT</div>
          </div>
          

          The JQuery & CSS is applied to these - telling the Cursor to change colour - However i cant find these two <div> s within your Carousel on the website - so the effect cant function?

          Talk soon & best wishes
          Richard

          B 1 Reply Last reply Feb 27, 2021, 12:10 PM
          0
          • R Richard
            Feb 27, 2021, 1:08 AM

            Dear @Baptiste

            On the codepen example you have the left & right <div>'s

            <div class="col">
              <div class="lay-carousel cursor-left">LEFT</div>
            </div>
            
            <div class="col">
              <div class="lay-carousel cursor-right">RIGHT</div>
            </div>
            

            The JQuery & CSS is applied to these - telling the Cursor to change colour - However i cant find these two <div> s within your Carousel on the website - so the effect cant function?

            Talk soon & best wishes
            Richard

            B Offline
            B Offline
            Baptiste
            wrote on Feb 27, 2021, 12:10 PM last edited by Baptiste Mar 2, 2021, 10:18 AM
            #5

            Hey @Richard-K,

            Maybe I'm doing something wrong but I target those div's on the codepen AND on my website by using that js code (you can see the complete code on the first message) :

            var cleft = document.querySelectorAll('.col .lay-carousel.cursor-left');
            var cright = document.querySelectorAll('.col .lay-carousel.cursor-right');
            

            I'm trying to reach this part of native lay's code :

            .col .lay-carousel.cursor-left {
                cursor: url("../img/cursor_prev.svg") 6 6, w-resize;
            }
            
            .col .lay-carousel.cursor-right {
                cursor: url("../img/cursor_next.svg") 6 6, e-resize;
            }
            

            To replace the native cursor as I do for the <a> elements

            Do I target the wrong class?

            Best,
            Baptiste.

            1 Reply Last reply
            0
            • B Offline
              B Offline
              Baptiste
              wrote on Mar 2, 2021, 9:15 AM last edited by Baptiste Mar 2, 2021, 10:19 AM
              #6

              Hello @arminunruh, any idea?
              Thanks 🙏

              1 Reply Last reply
              0
              • A Offline
                A Offline
                arminunruh
                Global Moderator
                wrote on Mar 8, 2021, 9:40 PM last edited by
                #7

                hey baptiste!

                you cannot do

                var cleft = document.querySelectorAll('.col .lay-carousel.cursor-left');
                

                Because the classes "carousel-left" and "carousel-right" are set dynamically whenever your mouse enters the carousel and either moves to the left or right, when you select '.col .lay-carousel.cursor-left' on page load, it will not match any html element

                Better do sth like:

                jQuery(".lay-carousel").on("mousemove", function(){
                	if( jQuery(this).hasClass("cursor-left") ){
                		// use left cursors
                	} else {
                		// use right cursors
                	}
                });
                jQuery(".lay-carousel").on("mouseleave", function(){
                	// go back to normal cursors
                });
                
                

                Your prototype is rlly cool and i think its a rlly nice creative solution, congrats!

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  Baptiste
                  wrote on Mar 8, 2021, 10:30 PM last edited by
                  #8

                  Hey @arminunruh,

                  Problem solved, thanks ✌️

                  Best,

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes

                  3/8

                  Feb 23, 2021, 8:13 AM

                  5 unread

                  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.
                  3 out of 8
                  • First post
                    3/8
                    Last post
                  0
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Search