mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-24 11:17:26 -04:00
bookmark jump animation
This commit is contained in:
parent
25890062df
commit
e428bbb018
3 changed files with 69 additions and 17 deletions
34
app/scripts/ui/menu/bookmark_jump_animation.gd
Normal file
34
app/scripts/ui/menu/bookmark_jump_animation.gd
Normal file
|
@ -0,0 +1,34 @@
|
|||
extends Control
|
||||
class_name BookmarkJumpAnimation
|
||||
|
||||
var base_position: Vector2
|
||||
var base_z_index: int
|
||||
var tween: Tween
|
||||
|
||||
|
||||
func start_jump_animation() -> void:
|
||||
base_position = position
|
||||
base_z_index = z_index
|
||||
z_index = 1
|
||||
|
||||
var up_position: Vector2 = base_position + Vector2(0, -6)
|
||||
var down_position: Vector2 = base_position + Vector2(0, 6)
|
||||
|
||||
if is_instance_valid(tween): tween.stop()
|
||||
tween = create_tween()
|
||||
tween.set_loops()
|
||||
|
||||
tween.tween_interval(1.0)
|
||||
tween.tween_property(self, "position", down_position, 0.15).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT)
|
||||
tween.tween_property(self, "position", up_position, 0.2).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT)
|
||||
tween.tween_property(self, "position", base_position, 0.15).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN)
|
||||
|
||||
|
||||
func stop_jump_animation() -> void:
|
||||
if is_instance_valid(tween): tween.stop()
|
||||
position = base_position
|
||||
z_index = base_z_index
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
stop_jump_animation()
|
|
@ -7,6 +7,7 @@ class_name BookmarkUI
|
|||
@export var title: Label
|
||||
@export var button: Button
|
||||
@export var special_effect: Panel
|
||||
@export var jump_animation: BookmarkJumpAnimation
|
||||
|
||||
var url: String
|
||||
var is_special: bool
|
||||
|
@ -14,8 +15,8 @@ var is_special: bool
|
|||
|
||||
func _ready() -> void:
|
||||
button.pressed.connect(on_pressed)
|
||||
ui_events.onboarding_started.connect(update_button_type)
|
||||
ui_events.onboarding_finished.connect(update_button_type)
|
||||
ui_events.onboarding_started.connect(update_special_effects)
|
||||
ui_events.onboarding_finished.connect(update_special_effects)
|
||||
|
||||
|
||||
func fill(gate: Gate) -> void:
|
||||
|
@ -24,20 +25,26 @@ func fill(gate: Gate) -> void:
|
|||
url = gate.url
|
||||
is_special = gate.is_special
|
||||
title.text = "Unnamed" if gate.title.is_empty() else gate.title
|
||||
update_button_type()
|
||||
update_special_effects()
|
||||
|
||||
var icon_path = gate.icon
|
||||
if icon_path.is_empty(): icon_path = await FileDownloader.download(gate.icon_url)
|
||||
|
||||
icon.texture = FileTools.load_external_tex(icon_path)
|
||||
|
||||
|
||||
|
||||
func update_button_type() -> void:
|
||||
func update_special_effects() -> void:
|
||||
if ui_events.is_onboarding_started:
|
||||
special_effect.visible = false
|
||||
jump_animation.stop_jump_animation()
|
||||
return
|
||||
|
||||
if is_special:
|
||||
special_effect.visible = true
|
||||
jump_animation.start_jump_animation()
|
||||
else:
|
||||
special_effect.visible = is_special
|
||||
special_effect.visible = false
|
||||
jump_animation.stop_jump_animation()
|
||||
|
||||
|
||||
func on_pressed() -> void:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue