Skip to content

Commit

Permalink
Initialize objects with properties where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandlo committed Apr 13, 2024
1 parent 79c77bb commit 91048a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
7 changes: 3 additions & 4 deletions demos/Animation/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ const animation_spring = new Adw.SpringAnimation({
value_to: 8.5,
spring_params: params,
target: target_spring,
initial_velocity: 1.0, // If amplitude of oscillation < epsilon, animation stops
epsilon: 0.001,
clamp: false,
});
animation_spring.initial_velocity = 1.0;
// If amplitude of oscillation < epsilon, animation stops
animation_spring.epsilon = 0.001;
animation_spring.clamp = false;

button_spring.connect("clicked", () => {
animation_spring.play();
Expand Down
13 changes: 8 additions & 5 deletions demos/Animation/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,14 @@ def animation_cb(value):
stiffness=50.0,
)
animation_spring = Adw.SpringAnimation(
widget=ball, value_from=0, value_to=1, spring_params=params, target=target_spring
widget=ball,
value_from=0,
value_to=1,
spring_params=params,
target=target_spring,
initial_velocity=1.0, # If amplitude of oscillation < epsilon, animation stops
epsilon=0.001,
clamp=False,
)
animation_spring.set_initial_velocity(1.0)
# If amplitude of oscillation < epsilon, animation stops
animation_spring.set_epsilon(0.001)
animation_spring.set_clamp(False)

button_spring.connect("clicked", lambda _: animation_spring.play())

0 comments on commit 91048a4

Please sign in to comment.