Skip to content

Commit 5e1d631

Browse files
authored
Example code for Animating on custom events (#4635) (#5552)
* Added a link to a glitch example in the animation doc for animating using custom events (#4635) * Removed the link to the custom event glitch examples, Added a custom event in the existing example and link to emitting custom events. * kept only startEvents in example and redirect link fix * animation and emit eventname changes
1 parent 0efad06 commit 5e1d631

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

docs/components/animation.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,19 @@ We can use the `startEvents` property to animate upon events:
140140
geometry="primitive: box"
141141
material="color: red"
142142
animation__mouseenter="property: components.material.material.color; type: color; to: blue; startEvents: mouseenter; dur: 500";
143-
animation__mouseleave="property: components.material.material.color; type: color; to: red; startEvents: mouseleave; dur: 500";>
143+
animation__mouseleave="property: components.material.material.color; type: color; to: red; startEvents: mouseleave; dur: 500";
144+
animation__customevent="property: components.material.material.color; type: color; from: red; to: blue; startEvents: triggeranimation; dur: 500";>
144145
</a-entity>
145146
```
146147

147148
[eventsglitch]: https://glitch.com/edit/#!/aframe-animation-events?path=index.html:1:0
148149

149150
[Remix the Animating on Events Glitch][eventsglitch].
150151

151-
To start an animation by explicitly emitting an event, you can do the following:
152+
To start an animation by explicitly [emitting a custom event](https://aframe.io/docs/1.6.0/introduction/javascript-events-dom-apis.html#emitting-an-event-with-emit), you can do the following:
152153

153154
```
154-
el.emit(`startanim001`, null, false);
155+
el.emit(`triggeranimation`, null, false);
155156
```
156157

157158
The [third parameter of emit](https://aframe.io/docs/1.6.0/core/entity.html#emit-name-detail-bubbles) set to "false" parameter ensures the event won't bubble up to parents, so that you can target the animation at just one particular element.

0 commit comments

Comments
 (0)