Skip to content

Commit

Permalink
Merge pull request tholman#55 from Proxy-99/a4
Browse files Browse the repository at this point in the history
text flag customization
  • Loading branch information
tholman authored Mar 21, 2023
2 parents 6ee6cc9 + 8eb9c35 commit 2a4d6f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ You can change the emoji in `emojiCursor`'s emoji with the `emoji` option (a lis
new cursoreffects.emojiCursor({ emoji: ["🔥", "🐬", "🦆"] });
```

### textFlag

You can change the `textFlag`'s text with the `text` option (String),
and color of the text with the `color` option (hex)

```js
new textFlag({text: "test",color:["#FF6800"]});
```

## 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.
Expand Down
3 changes: 3 additions & 0 deletions src/textFlag.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export function textFlag(options) {
let element = hasWrapperEl || document.body;

let text = cursorOptions.text ? " " + options.text : " Your Text Here";
let color = options?.color || "#000000";


let font = cursorOptions.font || "monospace";
let textSize = cursorOptions.textSize || 12;
Expand Down Expand Up @@ -119,6 +121,7 @@ export function textFlag(options) {
charArray[i].x = charArray[i - 1].x + gap;
charArray[i].y = charArray[i - 1].y;

context.fillStyle = color;
context.font = fontFamily;
context.fillText(charArray[i].letter, charArray[i].x, charArray[i].y);
}
Expand Down

0 comments on commit 2a4d6f7

Please sign in to comment.