# Is there something like a 'Single way animation', favorably triggered by JS ?

**URL:** https://forums.fusetools.com/t/is-there-something-like-a-single-way-animation-favorably-triggered-by-js/5145
**Category:** General
**Created:** [January 5, 2016, 7:11pm UTC](https://forums.fusetools.com/t/is-there-something-like-a-single-way-animation-favorably-triggered-by-js/5145 "2016-01-05T19:11:52Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Erik\_Terwan](https://avatars.discourse-cdn.com/v4/letter/e/d07c76/32.png) [@Erik\_Terwan](https://forums.fusetools.com/u/Erik_Terwan)
#### Post date: [January 5, 2016, 7:11pm UTC](https://forums.fusetools.com/t/is-there-something-like-a-single-way-animation-favorably-triggered-by-js/5145/1 "2016-01-05T19:11:52Z")

</div>

Hi!

Just started with fuse since yesterday evening, and i must say, it’s quite impressive! The FPS is really good, thank you OpenGL 😉

There is one thing i can’t find in the documentation, that is; a single way animation, right now when i press a button, and use something like the `<WhilePressed>` trigger, the animation always goes back to it’s resting state when i release the button.

Now i could work around this using a `<WhileTrue>` trigger, but i have a slighty more complicated use case in my head.

I’d like to create a Material Design inspired button, when you click it, a circle behind the button will scale up to the size of the screen, fading out quickly.

Right now i use an Observable and a trigger, i’ve set the DurationBack of the Animation properties to 0, and a setTimeout every time the button is hit. This kinda works, but using setTimeout is not very nice. Also, when you hit the button again before the animation / setTimeout is finished, nothing happens (of course).

How i would usually do this is by creating a new Circle view behind the button, scaling that up, and when the animation is done; removing the view from it’s parent.

Is something like this possible?

Thanks in advance,

Erik

---

<div class="post-metadata">

### Author: ![Bent](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/bent/32/157_2.png) [@Bent](https://forums.fusetools.com/u/Bent)
#### Post date: [January 5, 2016, 7:25pm UTC](https://forums.fusetools.com/t/is-there-something-like-a-single-way-animation-favorably-triggered-by-js/5145/2 "2016-01-05T19:25:16Z")

</div>

I’ll let someone else answer the trigger-thing, but as for the Material Design-inspired button, did you take a look at this example?

[https://www.fusetools.com/examples/material-upvote](https://www.fusetools.com/examples/material-upvote)

---

<div class="post-metadata">

### Author: ![Erik\_Terwan](https://avatars.discourse-cdn.com/v4/letter/e/d07c76/32.png) [@Erik\_Terwan](https://forums.fusetools.com/u/Erik_Terwan)
#### Post date: [January 5, 2016, 8:30pm UTC](https://forums.fusetools.com/t/is-there-something-like-a-single-way-animation-favorably-triggered-by-js/5145/3 "2016-01-05T20:30:02Z")

</div>

Yes, actually, i got inspired by that one. The thing is, that just animates between 2 states. What i’m looking for is a single animation, preferably triggered by JS, that just does one job.

Or even better, a way to insert new Views (is a Circle called a View or a Layer or what do you call it?) from JS, and maybe even launching Animations on the JS generated views.

---

<div class="post-metadata">

### Author: ![Erik\_Terwan](https://avatars.discourse-cdn.com/v4/letter/e/d07c76/32.png) [@Erik\_Terwan](https://forums.fusetools.com/u/Erik_Terwan)
#### Post date: [January 5, 2016, 8:53pm UTC](https://forums.fusetools.com/t/is-there-something-like-a-single-way-animation-favorably-triggered-by-js/5145/4 "2016-01-05T20:53:39Z")

</div>

Alright i think i’m getting the hang of it, doing so much programming in XML / UX takes some time to get used to!

What i did; made an Observable that’s an array of all the circles i’m going to use. Used the `<Each>` tag to iterate through that Observable, then i used the `<WhileTrue>` trigger to animate the element. I added a Callback with a handler that removes the first item in the Array, and it all works!

Still, i think it would be kinda nice to give some more power to JS, adding / modifying ux elements, in some use cases this can be handy. For now, i fixed it the ‘UX’ way.

Thanks!

---

<div class="post-metadata">

### Author: ![Vegard\_Strand\_Lende](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/vegard_strand_lende/32/349_2.png) [@Vegard\_Strand\_Lende](https://forums.fusetools.com/u/Vegard_Strand_Lende)
#### Post date: [January 6, 2016, 9:14am UTC](https://forums.fusetools.com/t/is-there-something-like-a-single-way-animation-favorably-triggered-by-js/5145/5 "2016-01-06T09:14:59Z")

</div>

Hi!

Sounds like you solved your issue? 🙂 I do agree that it could be handy to have more control over UX elements from JS, but a design decision we made was to keep a strict border between UX and JS since the moment you have UI leaks into your business logic or business logic leaks into your UI _the gates to hell will open_. For animation and other FPS dependent user experience features that you want to make should be done in UX or Uno 🙂

That said, if you know about some usecase where you can’t solve the issue without JS or it actually makes sense to do roundtrips to JS, please let me know! 🙂

---

<div class="post-metadata">

### Author: ![rasmusrim](https://avatars.discourse-cdn.com/v4/letter/r/b77776/32.png) [@rasmusrim](https://forums.fusetools.com/u/rasmusrim)
#### Post date: [January 18, 2017, 8:57am UTC](https://forums.fusetools.com/t/is-there-something-like-a-single-way-animation-favorably-triggered-by-js/5145/6 "2017-01-18T08:57:24Z")

</div>

Hi! I want to trigger an animation when a marker in a map is tapped. Putting a inside MapView does not work. The code would not show in the preview. I have urlencoded it. Decode it here: [http://meyerweb.com/eric/tools/dencoder/](http://meyerweb.com/eric/tools/dencoder/)

%3CMapView%20ux%3AName%3D%22map%22%20ShowMyLocation%3D%22True%22%20ShowMyLocationButton%3D%22True%22%3E%0A%20%20%20%20%3CMarkerTapped%3E%0A%20%20%20%20%20%20%20%20%3CChange%20whatever%20%2F%3E%0A%20%20%20%20%3C%2FMarkerTapped%3E%0A%0A%20%20%20%20%3CEach%20Items%3D%22%7Bcompanies.companies%7D%22%3E%0A%20%20%20%20%20%20%20%20%3CMapMarker%20Latitude%3D%22%7Blat%7D%22%20Longitude%3D%22%7Blong%7D%22%20Label%3D%22%7Bname%7D%22%20IconFile%3D%22%7Bpin%7D%22%20%2F%3E%0A%20%20%20%20%3C%2FEach%3E%0A%3C%2FMapView%3E

---

<div class="post-metadata">

### Author: ![Remi\_Pedersen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/remi_pedersen/32/432_2.png) [@Remi\_Pedersen](https://forums.fusetools.com/u/Remi_Pedersen)
#### Post date: [January 18, 2017, 9:01am UTC](https://forums.fusetools.com/t/is-there-something-like-a-single-way-animation-favorably-triggered-by-js/5145/7 "2017-01-18T09:01:50Z")

</div>

Please open a new thread for this (preferably in the “How To”-part of the forum) rather than reviving a really old one.

You can use [Github flavored markdown](https://help.github.com/articles/creating-and-highlighting-code-blocks/) to put code in your posts (basically just have a line with 3 backticks before and after the code blocks)
