Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="swipeloaders">
  <div class="homeloaderblack">
    <div class="target">
      <p id="text" class="text">FB</p>
    </div>
    <div class="target">
      <p class="text">IG</p>
    </div>
    <div class="target">
      <p class="text">LI</p>
    </div>

    <div class="cursor" id="cursor"></div>
  </div>
  <div class="homeloadergrey"></div>
  <div class="homeloaderlightgreen"></div>
</div>
              
            
!

CSS

              
                body {
  width: 100vw;
  height: 100vh;
  z-index: 1;
  margin: 0;
  padding: 0;
  position: relative;
  overflow: hidden;
}
.homeloadergrey {
  position: fixed;
  z-index: 5000;
  display: block;
  width: 100vw;
  height: 100vh;
  background-color: #323436;
}

.homeloaderlightgreen {
  position: fixed;
  z-index: 5001;
  display: block;
  width: 100vw;
  height: 100vh;
  background-color: #07da8a;
}

.homeloaderblack {
  position: fixed;
  z-index: 5002;
  display: block;
  width: 100vw;
  height: 100vh;
  background-color: #121212;
  display: flex;
}

.text {
  position: relative;
  color: white;
  margin: 0;
  user-select: none;
}
.target,
.cursor {
  border-radius: 50px;
  width: 0px;
  height: 0px;
  border: solid 1px #fff;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  position: absolute;
  top: 50%;
  left: 10%;
  -webkit-transform: translate(-50%, -50%) rotate(0deg);
  transform: translate(-50%, -50%) rotate(0deg);
}

/* Green Tri Small */
.target {
  border-radius: 0;
  position: relative;
  width: 80px;
  height: 80px;
  border: solid 1px #07da8a;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 50px;
}

              
            
!

JS

              
                console.clear();
const element = document.querySelector(".cursor");
const target = document.querySelector(".target");
const text = document.querySelector(".text");
class Cursor {
  constructor(el, target, text) {
    this.el = el;
    // this.target = target;
    // this.text = text;
    // this.triggerDistance = this.target.getBoundingClientRect().width;
    this.bind();
  }

  bind() {
    document.addEventListener("mousemove", this.move.bind(this), false);
  }

  move(e) {
    const cursorPosition = {
      left: e.clientX,
      top: e.clientY
    };
    document.querySelectorAll(".target").forEach((single) => {
      const triggerDistance = single.getBoundingClientRect().width;

      const targetPosition = {
        left:
          single.getBoundingClientRect().left +
          single.getBoundingClientRect().width / 2,
        top:
          single.getBoundingClientRect().top +
          single.getBoundingClientRect().height / 2
      };
      const distance = {
        x: targetPosition.left - cursorPosition.left,
        y: targetPosition.top - cursorPosition.top
      };

      const angle = Math.atan2(distance.x, distance.y);
      const hypotenuse = Math.sqrt(
        distance.x * distance.x + distance.y * distance.y
      );
      if (hypotenuse < triggerDistance) {
        // Nikhil - look at this code to adjust the round cursor area sizing
        TweenMax.to(this.el, 0.2, {
          left: targetPosition.left - (Math.sin(angle) * hypotenuse) / 2,
          top: targetPosition.top - (Math.cos(angle) * hypotenuse) / 2,
          height: single.clientHeight,
          width: single.clientWidth
        });
        TweenMax.to(single.querySelector(".text"), 0.2, {
          x: -((Math.sin(angle) * hypotenuse) / 2),
          y: -((Math.cos(angle) * hypotenuse) / 2)
        });
      } else {
        TweenMax.to(this.el, 0.2, {
          left: cursorPosition.left,
          top: cursorPosition.top,
          height: "12px",
          width: "12px"
        });

        TweenMax.to(single.querySelector(".text"), 0.2, {
          x: 0,
          y: 0
        });
      }
    });
    //     const targetPosition = {
    //       left:
    //         this.target.getBoundingClientRect().left +
    //         this.target.getBoundingClientRect().width / 2,
    //       top:
    //         this.target.getBoundingClientRect().top +
    //         this.target.getBoundingClientRect().height / 2
    //     };
    //     const distance = {
    //       x: targetPosition.left - cursorPosition.left,
    //       y: targetPosition.top - cursorPosition.top
    //     };
    //     const angle = Math.atan2(distance.x, distance.y);
    //     const hypotenuse = Math.sqrt(
    //       distance.x * distance.x + distance.y * distance.y
    //     );
    //     if (hypotenuse < this.triggerDistance) {
    //       TweenMax.to(this.el, 0.2, {
    //         left: targetPosition.left - (Math.sin(angle) * hypotenuse) / 2,
    //         top: targetPosition.top - (Math.cos(angle) * hypotenuse) / 2,
    //         height: target.clientHeight,
    //         width: target.clientWidth
    //       });
    //       TweenMax.to(document.querySelector(".text"), 0.2, {
    //         x: -((Math.sin(angle) * hypotenuse) / 2),
    //         y: -((Math.cos(angle) * hypotenuse) / 2)
    //       });
    //     } else {
    //       TweenMax.to(this.el, 0.2, {
    //         left: cursorPosition.left,
    //         top: cursorPosition.top,
    //         height: "12px",
    //         width: "12px"
    //       });
    //       TweenMax.to(document.querySelector(".text"), 0.2, {
    //         x: 0,
    //         y: 0
    //       });
    //     }
  }
}
const cursor = new Cursor(element, target);

              
            
!
999px

Console