Skip to content

Commit

Permalink
instructions on how to use locally
Browse files Browse the repository at this point in the history
  • Loading branch information
tholman committed Jan 25, 2023
1 parent f0a97d5 commit 1560849
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
},
"scripts": {
"build": "rollup -c",
"watch": "rollup -c -w",
"prepublish": "npm run build"
}
}
42 changes: 27 additions & 15 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# 90s Cursor Effects

_"Knowing the codes" used to be all the rage, I want to bring a few back._

A repo of the old effects that inspired creativity and the desire to learn at least a little code around the world. Modernised so they're a little more efficient, and just as annoying (and twice as fun) as they were before. [Have a play here](https://tholman.com/cursor-effects).

The current effects are:

- Rainbow Cursor
- Emoji Rain
- Elastic Emoji
Expand All @@ -16,6 +18,11 @@ The current effects are:
- Fairy Dust
- Clock Cursor

# How to Set Up Locally/Develop

1. First the packages request (this is only rollup, which code compilation) with `npm install`
2. `npm run watch` This will compile the src in the `dist` folder that `index.html` is looking for and update it when changes are made. You can then go to index.html in the web browser of your choice.

# How to Use

You need to include the following script tag in your webpage (see next section if you want to use this package via npm). And then, once the script is loaded you'll be able to add the effects to the page
Expand All @@ -28,7 +35,7 @@ Alternatively you can use a `type="module"` script on newer browsers with a impo

```html
<script type="module">
import { fairyDustCursor } from 'https://unpkg.com/cursor-effects@latest/dist/esm.js'
import { fairyDustCursor } from "https://unpkg.com/cursor-effects@latest/dist/esm.js";
new fairyDustCursor();
</script>
Expand All @@ -37,16 +44,16 @@ Alternatively you can use a `type="module"` script on newer browsers with a impo
And then create a new instance of its type in your JavaScript. The script will create the canvas that is used, so nothing else is really needed.

```js
window.addEventListener('load', (event) => {
window.addEventListener("load", (event) => {
new cursoreffects.ghostCursor();
});
```

You can also target specific elements, to have the canvas appear inside those, for example:

```js
const targetElement = document.querySelector("#ghost")
new cursoreffects.ghostCursor({element: targetElement});
const targetElement = document.querySelector("#ghost");
new cursoreffects.ghostCursor({ element: targetElement });
```

### or you can use NPM
Expand All @@ -56,8 +63,7 @@ npm install cursor-effects
```

```js
import { emojiCursor } from 'cursor-effects';

import { emojiCursor } from "cursor-effects";
new emojiCursor({ emoji: ["🔥", "🐬", "🦆"] });
```

Expand All @@ -70,49 +76,55 @@ A few of these have custom options as well (if you are interested in more option
You can change the colors, size and length in `rainbowCursor`

```js
new cursoreffects.rainbowCursor({length: 3, colors: ['red', 'blue'], size: 4});
new cursoreffects.rainbowCursor({
length: 3,
colors: ["red", "blue"],
size: 4,
});
```

### springyEmojiCursor

You can change the emoji in `springyEmojiCursor`'s emoji with the `emoji` a single string emoji.

```js
new cursoreffects.springyEmojiCursor({emoji: "🤷‍♂️"});
new cursoreffects.springyEmojiCursor({ emoji: "🤷‍♂️" });
```

### fairyDustCursor

You can change the emoji in `fairyDustCursor`'s colors with the `colors` option (an array of colors)

```js
new cursoreffects.fairyDustCursor({colors: ["#ff0000", "#00ff00", "#0000ff"]});
new cursoreffects.fairyDustCursor({
colors: ["#ff0000", "#00ff00", "#0000ff"],
});
```

### emojiCursor


You can change the emoji in `emojiCursor`'s emoji with the `emoji` option (a list of emoji)

```js
new cursoreffects.emojiCursor({emoji: ["🔥", "🐬", "🦆"]});
new cursoreffects.emojiCursor({ emoji: ["🔥", "🐬", "🦆"] });
```

## Accessibility

The cursor won't display if the user's system accessibility settings have [prefers-reduced-motion](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion) enabled.

### trailingCursor


You can change the number of trail steps in `trailingCursor` with the `particles` option (a number)

```js
new cursoreffects.trailingCursor({particles: 15});
new cursoreffects.trailingCursor({ particles: 15 });
```

You can change the color of the following dot in `followingDotCursor` with the `color` option (hex)

```js
new cursoreffects.followingDotCursor({color: ["#323232a6"]})

new cursoreffects.followingDotCursor({ color: ["#323232a6"] });
```

# License
Expand Down

0 comments on commit 1560849

Please sign in to comment.