Skip to content

Conversation

@kewalkishang
Copy link
Contributor

Description:
Need for example regarding the use of custom events to trigger animations in A-Frame. The current documentation does not explicitly show how to use the .emit() function to start animations based on custom events, which can be confusing for new users.

Changes proposed:

  • Created a glitch example that demonstrates how to trigger animations using startEvents, pauseEvents, resumeEvents for custom events and then emitting them.
  • Added a link to the glitch example in the animation doc.

@kewalkishang kewalkishang changed the title Example code for Animating on custom events (aframevr#4635) Example code for Animating on custom events #4635 Jun 30, 2024
@kewalkishang kewalkishang changed the title Example code for Animating on custom events #4635 Example code for Animating on custom events (#4635) Jun 30, 2024
@dmarcos
Copy link
Member

dmarcos commented Jul 1, 2024

Thanks. The example uses an old version of A-Frame (1.6.0). Also I don't see any animations being triggered. I might be missing something

@kewalkishang
Copy link
Contributor Author

Hi @dmarcos, thanks for the review.
Updated A-Frame to the latest version (Had made the example a while back).
The animation is on the cube. It changes its color from Red to blue in 2.5 seconds now(It was 5 seconds before). The idea was to give users ample time to pause the animation in between and try the pauseEvents and resumeEvents as well.
Do let me know how I can make the example even better.

Best,
Kewal

@dmarcos
Copy link
Member

dmarcos commented Nov 12, 2024

Thanks for the patience. I'm reluctant to add more glitches to the examples because those need maintenance too and easily go out of date. Could we handle this by adding a couple of lines and pointing to the custom events section of the docs?

https://aframe.io/docs/1.6.0/introduction/javascript-events-dom-apis.html#emitting-an-event-with-emit

Thanks

@kewalkishang
Copy link
Contributor Author

Hey @dmarcos.
I see. Makes sense.
Added a simple custom event in the existing example and a link to the custom events section for reference.
Changes
Do let me know if this is what you had in mind.

Thanks.

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.

@dmarcos
Copy link
Member

dmarcos commented Nov 18, 2024

Thanks. One more comment

@dmarcos
Copy link
Member

dmarcos commented Nov 20, 2024

Thanks so much for sticking with it!

@dmarcos dmarcos merged commit 5e1d631 into aframevr:master Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants