Skip to content

Edge-Drop is a clipboard shelf on the edge of your screen. Hover to open it. Drag files and images into any app, click to copy text and links. Free and open-source for Windows.

perf(loader): pause GSAP animation tickers when edge panel is collapsed

Deepender2562d72ec7d68c
diff --git a/src/components/LiquidOctopusLoader.tsx b/src/components/LiquidOctopusLoader.tsx
index 618e862..9304d7f 100644
--- a/src/components/LiquidOctopusLoader.tsx
+++ b/src/components/LiquidOctopusLoader.tsx
@@ -1,5 +1,6 @@
import { useEffect, useRef, useMemo } from 'react'
import gsap from 'gsap'
+import { useStore } from '../store/appStore'
// Raw SVG Path for the Central Octopus Logo
const OCTO_PATH =
@@ -9,15 +10,23 @@ interface LiquidLoaderProps {
fillColor?: string
glowColor?: string
speed?: number
+ active?: boolean
}
export function LiquidOctopusLoader({
fillColor = '#ffffff',
glowColor = 'rgba(255, 255, 255, 0.9)',
- speed = 1.0
+ speed = 1.0,
+ active
}: LiquidLoaderProps) {
const octoRef = useRef<SVGPathElement | null>(null)
+ const open = useStore((s) => s.open)
+ const copyFlareActive = useStore((s) => s.copyFlareActive)
+ const settingsOpen = useStore((s) => s.settingsOpen)
+
+ const isAnimating = active ?? (open || copyFlareActive || settingsOpen)
+
// Octopus path dimensions & center coordinates
const bounds = useMemo(() => {
const coords = OCTO_PATH.match(/-?\d*\.?\d+/g) || []
@@ -45,7 +54,7 @@ export function LiquidOctopusLoader({
useEffect(() => {
// 1. Gentle logo pulse & breathing
- const mainTl = gsap.timeline({ repeat: -1 })
+ const mainTl = gsap.timeline({ repeat: -1, paused: !isAnimating })
mainTl.to(
octoRef.current,
{
@@ -76,11 +85,19 @@ export function LiquidOctopusLoader({
}
)
+ if (!isAnimating) {
+ mainTl.pause()
+ rotTween.pause()
+ } else {
+ mainTl.play()
+ rotTween.play()
+ }
+
return () => {
mainTl.kill()
rotTween.kill()
}
- }, [speed, bounds])
+ }, [speed, bounds, isAnimating])
return (
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', width: '100%', height: '100%' }}>