Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Animations and running them when screen turns on..

ANSWERED

Hello dev world. I have a watch face running a couple of animations.  I use the function to delay the animation time. The trouble is I want this animation to happen every time the watch face comes on. I get the feeling currently that the animation is always running no matter what ( if i have it on infinite) which in turn i would assume would have an affect on the battery. 

I have tried different things in terms of enable etc but none of these seem to activate when the screen comes on and runs everything else. 

Now, it works when i use the click as the begin point but so is there something simple I am missing or do i just have run with it and play around with the animation setting to limit the drain on the battery.

 

Thanks in advance.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions
import { display } from "display";

display.addEventListener("change", function() {
  if (display.on) {
    wake();
  } else {
    sleep();
  }
})

function wake() {
  // do something when the screen wakes
// https://dev.fitbit.com/build/guides/user-interface/animations/#javascript-animations
myinstance.animate("enable"); // Specify the name of the event to trigger } function sleep() {
// do something when the screen sleeps }

 

View best answer in original post

Best Answer
0 Votes
2 REPLIES 2
import { display } from "display";

display.addEventListener("change", function() {
  if (display.on) {
    wake();
  } else {
    sleep();
  }
})

function wake() {
  // do something when the screen wakes
// https://dev.fitbit.com/build/guides/user-interface/animations/#javascript-animations
myinstance.animate("enable"); // Specify the name of the event to trigger } function sleep() {
// do something when the screen sleeps }

 

Best Answer
0 Votes

Worked a treat, thank you

Best Answer
0 Votes