I wouldn’t use a GIF because you can’t control the timing, and I’m doubting is more memory efficient. But here’s a basic example:
<App>
<JavaScript>
var Observable = require('FuseJS/Observable');
var isOn = Observable(false);
function changeLight() {
isOn.value = !isOn.value;
setTimeout(changeLight, 100);
}
changeLight();
module.exports = {
isOn: isOn
}
</JavaScript>
<Circle ux:Name="light" Width="100" Height="100">
<WhileTrue Value="{isOn}">
<Change Target="light.Color" Value="Green" />
</WhileTrue>
</Circle>
</App>
Notice I don’t use setInterval you shouldnt use it, call setTimeout at the end of the function call, this guarentees that the last call was finished before being added to the javascript event loop. setInterval would keep calling the function even if the function has not finished running
It’d be interesting to know if there’s a full ux only way of doing this
@ALL Thanks guys, and yeh I was gonna go the JS route… or GIF …
@Kristian so awesome man, so glad there is a pure UX way of doing it! Although I though it’d be simpler haha. Perhaps ya’ll should add this to your Animation stack… and calling the effect Blink, Fade, Pulse, Beat … with extra parameter LoopCount = number of blinks or infinite looping … That would be rad.
Now that I think about it though, would a GIF be more CPU friendly (at a little more expense to memory) vs programatically blinking the darn thing? Since:
JS is on separated thread which needs to run along w/ business logic, and then communicate to Native UI thread
Now that I think about it though, would a GIF be more CPU friendly (at a little more expense to memory) vs programatically blinking the darn thing?
No, the pure UX approach is the way to go.
Currently I believe the only way to support animated GIFs in Fuse is by putting them inside a WebView and I really wouldn’t expect this to change in the near future: animated GIFs are simply not the right tool for app development
Now that I think about it though, would a GIF be more CPU friendly (at a little more expense to memory) vs programatically blinking the darn thing?
No, the pure UX approach is the way to go.
Currently I believe the only way to support animated GIFs in Fuse is by putting them inside a WebView and I really wouldn’t expect this to change in the near future: animated GIFs are simply not the right tool for app development
oohhh i thought Animated GIFs worked right off the bat as a regular image component …