Skip to content

Commit 9b24220

Browse files
committed
Updated rand example
1 parent 38e8d94 commit 9b24220

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

docs/api/shape-swirl/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ShapeSwirl
22

33
- [CodePen Example](https://codepen.io/sol0mka/pen/pbebwQ?editors=0010)
4-
- [Shape API](shape.md)
4+
- [Shape API](../shape/README.md)
55
- [Tween API](../tweens/tween.md)
66

77
Full API reference:

docs/api/syntax/rand.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,36 @@ Full API reference:
1515
```
1616

1717
::: 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-
```
18+
If you wanna update the random value after it's been declared, you can use the `generate()` function.
2819
:::
2920

21+
## Example usage
22+
3023
<MojsInteractive
3124
id="example"
3225
autoplay
33-
height="200px"
26+
height="400px"
3427
global="example"
28+
:controller=false
29+
notice="Click anywere to see the updated random value"
3530
code=
36-
"const example = new mojs.Burst({
37-
radius: { 'rand(4, 40)' : 'rand(50, 100)' }
31+
"const example = new mojs.ShapeSwirl({
32+
parent: '#example',
33+
left: 0, top: 0,
34+
duration: 'rand(600, 1000)',
35+
radius: 'rand(10, 20)',
36+
pathScale: 'rand(.5, 1)',
37+
swirlFrequency: 'rand(2, 4)',
38+
swirlSize: 'rand(6, 14)',
3839
});
3940

40-
document.addEventListener( 'click', function (e) {
41-
example.generate().replay();
41+
document.getElementById('example').addEventListener( 'click', function (e) {
42+
const x = e.layerX,
43+
y = { [e.layerY]: e.layerY - 150 };
44+
example
45+
.tune({ x, y })
46+
.generate()
47+
.replay();
4248
});
4349

4450
example.play();"

0 commit comments

Comments
 (0)