@@ -755,23 +755,28 @@ def _animate_switch(self):
755
755
# switch is going from on->off or off->on
756
756
757
757
if self ._animation_time == 0 :
758
- self ._draw_position (0 )
759
- break
760
- # constrain the elapsed time
761
- elapsed_time = time .monotonic () - start_time
762
- if elapsed_time > self ._animation_time :
763
- elapsed_time = self ._animation_time
764
-
765
- if self ._value :
766
- position = (
767
- 1 - (elapsed_time ) / self ._animation_time
768
- ) # fraction from 0 to 1
769
- else :
770
- position = (elapsed_time ) / self ._animation_time # fraction from 0 to 1
771
-
772
- # Update the moving elements based on the current position
773
- # apply the "easing" function to the requested position to adjust motion
774
- self ._draw_position (easing (position )) # update the switch position
758
+ if not self ._value :
759
+ position = 1
760
+ self ._draw_position (1 )
761
+ else :
762
+ position = 0
763
+ self ._draw_position (0 )
764
+ else : #animate over time
765
+ # constrain the elapsed time
766
+ elapsed_time = time .monotonic () - start_time
767
+ if elapsed_time > self ._animation_time :
768
+ elapsed_time = self ._animation_time
769
+
770
+ if self ._value :
771
+ position = (
772
+ 1 - (elapsed_time ) / self ._animation_time
773
+ ) # fraction from 0 to 1
774
+ else :
775
+ position = (elapsed_time ) / self ._animation_time # fraction from 0 to 1
776
+
777
+ # Update the moving elements based on the current position
778
+ # apply the "easing" function to the requested position to adjust motion
779
+ self ._draw_position (easing (position )) # update the switch position
775
780
776
781
# update the switch value once the motion is complete
777
782
if (position >= 1 ) and not self ._value :
0 commit comments