Apply A Cursor-Mouse_Follower To Your Website

Apply A Cursor-Mouse_Follower To Your Website

Table of contents

No heading

No headings in the article.

Cursor mouse follower is a powerful javascript library to create amazing and smooth effects for the mouse cursor on your website.

HTML Example:

<!DOCTYPE html>
<html>
    <title>Cursor Mouse Follower</title>
    <head>
   </head>
     <body>
         <div class="header">
            <a href="#logo" class="logo">Code-it_Write-it</a>
            <div class="header-right">
                <a href="#home" class="active">Home</a>
                <a href="#about">About</a>
                <a href="#service" >Services</a>
                <a href="#solution">Solution</a>
                <a href="#contact">Contact</a>
            </div>
        </div>
        <section>
         <div class="container">
         <h1 class="h1" data-cursor-text="Welcome!!!" data-cursor-stick>Welcome to Code-it_Write-it</h1>
  <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum</p>
 <p class="img" data-cursor-img="code.jpg"><img src="" class="show-img" >Hover me to view image!</p>
 </div>
 </section>


</body>
</html>

To add a cursor mouse follower in your existing or new website.

You need to add the following to your code

Add CDN to the <head> </head> tag

Add the following CDN:

<link rel="stylesheet" href="https://unpkg.com/mouse-follower@1/dist/mouse-follower.min.css">

<script src="https://unpkg.com/mouse-follower@1/dist/mouse-follower.min.js"></script>

Mouse Follower requires GSAP library to work. You need to import it, if you didn't have it before:

<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.10.4/gsap.min.js"></script>
<script src="https://unpkg.com/mouse-follower@1/dist/mouse-follower.min.js"></script>

Choose from option, add in a <script> </script> tag below closing </body>

You can configure Mouse Follower via Two options:

Option 1:

You can use mouse follower for a specific area of your code, either container section or any pointing to the class name

const cursor = new MouseFollower({
    container: '.container',
    speed: 0.3
});

Option 2:

The following options with defaults are available for the entire body of the website:

const cursor = new MouseFollower({
    el: null,
    container: document.body,
    className: 'mf-cursor',
    innerClassName: 'mf-cursor-inner',
    textClassName: 'mf-cursor-text',
    mediaClassName: 'mf-cursor-media',
    mediaBoxClassName: 'mf-cursor-media-box',
    iconSvgClassName: 'mf-svgsprite',
    iconSvgNamePrefix: '-',
    iconSvgSrc: '',
    dataAttr: 'cursor',
    hiddenState: '-hidden',
    textState: '-text',
    iconState: '-icon',
    activeState: '-active',
    mediaState: '-media',
    stateDetection: {
        '-pointer': 'a,button',
        '-hidden': 'iframe'
    },
    visible: true,
    visibleOnState: false,
    speed: 0.55,
    ease: 'expo.out',
    overwrite: true,
    skewing: 0,
    skewingText: 0,
    skewingIcon: 2,
    skewingMedia: 2,
    skewingDelta: 0.001,
    skewingDeltaMax: 0.15,
    stickDelta: 0.15,
    showTimeout: 20,
    hideOnLeave: true,
    hideTimeout: 300,
    hideMediaTimeout: 300
});

Output:

View website live