Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example code for Animating on custom events (#4635) #5552

Merged
merged 5 commits into from
Nov 20, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/components/animation.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,16 @@ We can use the `startEvents` property to animate upon events:
geometry="primitive: box"
material="color: red"
animation__mouseenter="property: components.material.material.color; type: color; to: blue; startEvents: mouseenter; dur: 500";
animation__mouseleave="property: components.material.material.color; type: color; to: red; startEvents: mouseleave; dur: 500";>
animation__mouseleave="property: components.material.material.color; type: color; to: red; startEvents: mouseleave; dur: 500";
animation__customevent="property: components.material.material.color; type: color; from: red; to: blue; startEvents: startanim001; dur: 500";>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we change the event name? startanim001 not super friendly. What about 'triggeranimation`?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing! I initially named it "startanim001" because we had an emit event with the same name right below. I'll change both the event name and the emit to "triggeranimation" for consistency.

</a-entity>
```

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

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

To start an animation by explicitly emitting an event, you can do the following:
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:

```
el.emit(`startanim001`, null, false);
Expand Down
Loading