Skip to content

Commit f9d8c7b

Browse files
committedNov 1, 2020
Added a generate example to rand api
1 parent 2c048ea commit f9d8c7b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
 

‎docs/api/syntax/rand.md

+31
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,35 @@ Full API reference:
1414

1515
```
1616

17+
::: tip
18+
If you wanna update the random value after it's been declared, you can use the `generate()` function:
19+
```js
20+
const example = new mojs.Burst({
21+
radius: { 'rand(4, 40)' : 'rand(50, 100)' }
22+
});
23+
24+
document.addEventListener( 'click', function (e) {
25+
example.generate().replay();
26+
});
27+
```
28+
:::
29+
30+
<MojsInteractive
31+
id="example"
32+
autoplay
33+
height="200px"
34+
global="example"
35+
code=
36+
"const example = new mojs.Burst({
37+
radius: { 'rand(4, 40)' : 'rand(50, 100)' }
38+
});
39+
40+
document.addEventListener( 'click', function (e) {
41+
example.generate().replay();
42+
});
43+
44+
example.play();"
45+
>
46+
</MojsInteractive>
47+
1748
- [CodePen Example](https://codepen.io/sandstedt/pen/dyXevEE?editors=0010)

0 commit comments

Comments
 (0)