Jump to content

Parallax/magnetic mouse cursor

Recommended Posts

Is there a way I can get a parallax/magnetic mouse cursor to my squarespace website?
Like these website- https://www.minimist.ca/ and https://studiomaertens.com/about

I've posted this in Settings > Advanced > Header 

<script src="//ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

And this in Settings > Advanced > Footer

<script>

  $( ( ) => {
  
    $( 'body' ).prepend ( '<div class="cursor cursor-dot" style="left: 0px; top: 0px;">' );
  
    $( window ).mousemove ( function ( e ) {
    
      $( '.cursor' ).css ( {
      
        left: e.pageX,
        top: e.pageY
        
        } );
        
      } );
      
    $( window ).mousemove ( function ( e ) {
    
      $( 'a' ).on ( 'mouseenter', function ( ) {
        
        $( '.cursor' ).addClass ( 'active' );
        
        } );
        
      } );
      
    $( window ).mousemove ( function ( e ) {
    
      $( 'a' ).on ( 'mouseleave', function ( ) {
      
        $( '.cursor' ).removeClass ( 'active' );
        
        } );
        
      } );
      
    } );
    
  </script>

After doing that I've also pasted this in Design > Custom CSS
 

@media ( hover: none ) {

  .cursor {
  
    display: none !important;
    
    }
  }

* {

  cursor: none;
  
  }

.cursor {

  --size: 10px;
  
  height: var( --size );
  width: var( --size );
  
  border-radius: 50%;
  pointer-events: none;
  position: absolute;
  transform: translate( -50%, -50% );
  z-index: 99999999999;
  
  }

.cursor.cursor-dot {

  background: #ffffff; /* This defines the color of the cursor */
  mix-blend-mode: difference; /* This line is for the circle to invert Delete this line if you dont want the circle to invert */
  transition: width 0.8s, height 0.7s, background-color 0.9s;
  transition-timing-function: ease-out;
  
  }

.cursor-dot.active {

  --size: 60px;
  
  background-color: #ffffff;
  
  }

What I can't seem to get is the "finger pointing" on hover out of the way. And if it's possible, can any improvements be made so it only inverts when hovering on black and white?

Thank you very much.

Edited by CollinC
Link to comment
  • 4 weeks later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.