diff --git a/examples/card/src/App.tsx b/examples/card/src/App.tsx
index 37a5bab1..8c782cf6 100644
--- a/examples/card/src/App.tsx
+++ b/examples/card/src/App.tsx
@@ -14,10 +14,9 @@ import {
CardTitle,
Switch,
} from '@react-three/uikit-default'
-import { useMemo, useRef } from 'react'
-import { signal } from '@preact/signals-core'
+import { useMemo, useRef, useState } from 'react'
+import { Signal, signal } from '@preact/signals-core'
import { easing, geometry } from 'maath'
-import { Floating, Physical } from './components/Simulation.js'
setPreferredColorScheme('light')
const notifications = [{ title: 'Your call has been confirmed.', description: '1 hour ago' }]
@@ -38,32 +37,93 @@ export default function App() {
Source Code
-
-
)
}
-function Rig() {
- useFrame((state, delta) => {
- easing.damp3(state.camera.position, [state.pointer.x * 2, state.pointer.y * 2, 18], 0.35, delta)
- state.camera.lookAt(0, 0, -10)
- })
- return null
-}
-
const cardGeometry = new geometry.RoundedPlaneGeometry(1, 1, 0.025)
+const Panel = ({ shown$ }: { shown$: Signal }) => {
+ return (
+ shown$.value && (
+
+
+
+ Notifications
+
+
+ You have 3 unread messages.
+
+
+
+
+
+
+
+ Push Notifications
+
+
+ Send notifications to device.
+
+
+
+
+
+
+ {notifications.map((notification, index) => (
+
+
+
+
+ {notification.title}
+
+
+ {notification.description}
+
+
+
+ ))}
+
+
+
+
+
+
+ )
+ )
+}
+
export function CardPage() {
const openRef = useRef(false)
- const translateY = useMemo(() => signal(-460), [])
- const translateZ = useMemo(() => signal(0), [])
- useFrame((_, delta) => {
- easing.damp(translateY, 'value', openRef.current ? 0 : -460, 0.2, delta)
- easing.damp(translateZ, 'value', openRef.current ? 200 : 0, 0.2, delta)
- })
+ const shown$ = useMemo(() => signal(false), [])
return (
@@ -71,11 +131,11 @@ export function CardPage() {
backgroundColor={0xffffff}
dark={{ backgroundColor: 0x0 }}
borderRadius={20}
- onClick={(e) => (e.stopPropagation(), (openRef.current = !openRef.current))}
+ onClick={(e) => (e.stopPropagation(), (shown$.value = !shown$.value))}
cursor="pointer"
flexDirection="column"
zIndex={10}
- transformTranslateZ={translateZ}
+ transformTranslateZ={200}
>
@@ -83,7 +143,7 @@ export function CardPage() {
-
+ {/**/}
@@ -115,75 +175,7 @@ export function CardPage() {
-
-
-
- Notifications
-
-
- You have 3 unread messages.
-
-
-
-
-
-
-
- Push Notifications
-
-
- Send notifications to device.
-
-
-
-
-
-
- {notifications.map((notification, index) => (
-
-
-
-
- {notification.title}
-
-
- {notification.description}
-
-
-
- ))}
-
-
-
-
-
-
+