jump animation problem

Godot Version

4.2.2 stable

Question

how do I fix this code so that the player have only a certain frame when falling
and have a jump animation when he was on the floor?

the jump animation code

	if not is_on_floor():
		animatedS.play("jump")
		if Input.is_action_just_pressed("ui_accept"):
			var f = animatedS.get_frame()
			if f == 7 :
				animatedS.pause()
		else:
			animatedS.set_fr

full code:

extends CharacterBody2D

var d = 0
const SPEED = 300.0
const JUMP_VELOCITY = -400.0
@onready var animatedS = $AnimatedSprite2D

#Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")



func animation(d):
	if d > 0:
		animatedS.flip_h = false
	elif d < 0:
		animatedS.flip_h = true

	if not is_on_floor():
		animatedS.play("jump")
		if Input.is_action_just_pressed("ui_accept"):
			var f = animatedS.get_frame()
			if f == 7 :
				animatedS.pause()
		else:
			animatedS.set_frame(7)
			
	
	elif d != 0:
		animatedS.play("walk")
	else:
		animatedS.play("idle")

func _physics_process(delta):

# Add the gravity.
	if not is_on_floor():
		velocity.y += gravity * delta
# Handle jump.
	if Input.is_action_just_pressed("ui_accept") and is_on_floor():
		velocity.y = JUMP_VELOCITY

# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
	var direction = Input.get_axis("ui_left", "ui_right")
	d = direction
	if direction:
		velocity.x = direction * SPEED
		
	else:
		velocity.x = move_toward(velocity.x, 0, SPEED)
	
	#handle the animation
	animation(direction)


	move_and_slide()