Skip to content

Commit 899e0b2

Browse files
Update README.md
1 parent 980c7ba commit 899e0b2

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,7 @@ TinyEvents is available on NPM, Yarn, and GitHub. You can use any of the followi
5757
5858
import tinyEvents from 'tinyevents';
5959
60-
const getRandomColor = () =>
61-
"#" + Math.floor(Math.random() * 16777215).toString(16);
62-
63-
const triggerColorChange = (color) => {
64-
// Custom events demo
65-
tinyEvents("#color-code").trigger("color-change", {
66-
color
67-
});
68-
};
69-
70-
tinyEvents(".change-bg").on("click.sample", () => {
60+
tinyEvents(".change-bg").on("click.sample mouseover.sample", () => {
7161
const color = getRandomColor();
7262
document.body.style.backgroundColor = color;
7363
triggerColorChange(color);
@@ -88,7 +78,16 @@ tinyEvents("#color-code").on("color-change", (event) => {
8878
document.getElementById("color-code").innerHTML = color;
8979
});
9080
81+
function getRandomColor() {
82+
return "#" + Math.floor(Math.random() * 16777215).toString(16);
83+
}
9184
85+
function triggerColorChange(color) {
86+
// Custom events demo
87+
tinyEvents("#color-code").trigger("color-change", {
88+
color
89+
});
90+
}
9291
9392
```
9493

0 commit comments

Comments
 (0)