0.4.2 • Published 2 years ago

@dinoly/trail v0.4.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Trail

NPM version Github action License

Milestones

NOTE: This is a Work In Progress project.

Trail, Generates a trail behind an Html element.

look into the Change log for features and breaking changes

Content Outline

Introduction

Place the following <script> near the end of your pages, right before the closing </body> tag.

<script src="https://cdn.jsdelivr.net/npm/@dinoly/trail@0.3.6/trail.min.js" crossorigin="anonymous"></script>

After the above script, make a new trail object and pass in the class of the element you want to create a trail behind.

<script>
  const move = new Trail({
    target: "circle"
  });
  move.followMouse();
</script>

Sample code

Html

<!-- index.html -->
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
  <meta charset="utf-8">
  <title>Trail</title>
  <link rel="stylesheet" href="./styles.css" /> <!-- Link to the style sheet with circle's custom styling  -->
</head>

<body>
  <div class="circle"></div>
  <script src="https://cdn.jsdelivr.net/npm/@dinoly/trail@0.3.6/trail.min.js" crossorigin="anonymous"></script>
  <script>
    const move = new Trail({
      target: "circle",
    });
    move.followMouse();
  </script>
</body>

</html>

Css

/* styles.css */
body {
  margin: 0;
  padding: 0;
  background: black;
  width: 100vw;
  height: 100vh;
}
* {
  cursor: none;
}
.circle {
  background-color: lightblue;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  pointer-events: none;
  margin: 10px; /* will be removed */
}

Arguments

{
  target: None,
  area: None,
  particle: "default", // self
  color: "default", // white
  isnode: true,
  effect: "default", // straight
  trails: false
}
NameDescriptioncodetypes
targetIs the class of the element behind which the trail will be generated.target: "example"none
areaIs the class of the element inside which the trail will be generated.area: "example"none
particleShape of the particle in trail, default: selfparticle: "circle""circle", "triangle", "square"
colorColor of the trail, default: whitecolor: "mediumseagreen"none
isnodeSet false if you want a trail for a Text or Svg, default: trueisnode:falsenone
effectBehavior of the particleeffect:"spread""spread", "rotate"
trailsIf true will create trails with multiple particles, currently 2.trails:truenone

Note: if this creates a lag, use the effect: "spread" which will create similar effect with one particle.

Methods

NameDescriptioncode
followMouseMake the Html element follow the Mouse Pointer with a trail.Trail.followMouse();
followNodeDoes not make the Html element follow the Mouse Pointer, add CSS to move the element how ever you like.Trail.followNode();
activeAreamake the Html element follow the Mouse Pointer when mouse hover a certain element, set with area: <class-of-area>Trail.activeArea();

Gifs

Bugs and Future Improvements

Bugs :bug:

  • Text offset.

Improvements

  • Resizing the trail.
  • Trail behind multiple elements with one Trail object.
  • More Effects and Particles.
  • Support for nested elements.
0.4.1

2 years ago

0.4.2

2 years ago

0.3.6

3 years ago

0.3.5

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.3.2

3 years ago

0.4.0

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.1

3 years ago

0.1.2

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.1.3

3 years ago

0.1.0

3 years ago