@@ -754,21 +754,30 @@ def _animate_switch(self):
754
754
# Determines the direction of movement, depending upon if the
755
755
# switch is going from on->off or off->on
756
756
757
- # constrain the elapsed time
758
- elapsed_time = time .monotonic () - start_time
759
- if elapsed_time > self ._animation_time :
760
- elapsed_time = self ._animation_time
761
-
762
- if self ._value :
763
- position = (
764
- 1 - (elapsed_time ) / self ._animation_time
765
- ) # fraction from 0 to 1
766
- else :
767
- position = (elapsed_time ) / self ._animation_time # fraction from 0 to 1
768
-
769
- # Update the moving elements based on the current position
770
- # apply the "easing" function to the requested position to adjust motion
771
- self ._draw_position (easing (position )) # update the switch position
757
+ if self ._animation_time == 0 :
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
+ # fraction from 0 to 1
776
+ position = (elapsed_time ) / self ._animation_time
777
+
778
+ # Update the moving elements based on the current position
779
+ # apply the "easing" function to the requested position to adjust motion
780
+ self ._draw_position (easing (position )) # update the switch position
772
781
773
782
# update the switch value once the motion is complete
774
783
if (position >= 1 ) and not self ._value :
0 commit comments