Follow The Cursor | onmousemove addEventListener Javascript

 Follow The Cursor | on mousemove addEventListener Javascript


Easy Cursor Follow | on mousemove

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Follow the Cursor</title>

  <style>
    body {
      margin0;
      padding0;
      displayflex;
      align-itemscenter;
      justify-contentcenter;
      height100vh;
      width100%;
      background-colorblack;
      positionrelative;
      overflowhidden;
    }

    h1 {
      color#ffffff;
      font-size3em;
      text-transformcapitalize;
      font-familysans-serif;
    }

    #cursor {
      height35px;
      width35px;
      border-radius50%;
      background-colortransparent;
      border3px solid #ffffff;
      positionabsolute;
      box-sizingborder-box;
      transition0.1s linear;
      pointer-eventsnone;
      transformtranslate(-50%-50%);
    }

    h1:hover~#cursor {
      transformscale(4);
      border2px solid #ffffff;
    }
  </style>
</head>

<body>
  
  <h1>Follow The Cursor | onmousemove addEventListener Javascript</h1>
  <span id="cursor"></span>

  <script>
    const cursor = document.getElementById("cursor");
    //step 1
    window.addEventListener("mousemove"function (Event{
      var x = Event.clientX;
      var y = Event.clientY;
      cursor.style.left = x + "px";
      cursor.style.top = y + "px";
    });
    ////step 2
    // window.addEventListener('mousemove', (event) => {
    //   cursor.style.left = event.clientX;
    //   cursor.style.top = event.clientY;
    // });
  </script>

</body>

</html>

Comments

Popular posts from this blog

(gradle-2.13-all)-Exception in thread "main" java.lang.RuntimeException: java.io.IOException: Server returned HTTP response code: 403 for URL: http://services.gradle.org/distributions/gradle-2.13-all.zip

LetsLearn JavaScript

Cordova App for Publishing to an App Store - Steps by Steps (https://docs.microsoft.com/)