Skip to content

Commit

Permalink
Add example for dragOver
Browse files Browse the repository at this point in the history
  • Loading branch information
haywirez committed Jul 15, 2022
1 parent 44919d0 commit 1b7f27c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
31 changes: 31 additions & 0 deletions example/src/demos/FileDragDrop.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React, { useState } from 'react'
import { Canvas } from '@react-three/fiber'
import { a, useSpring } from '@react-spring/three'
import { OrbitControls } from '@react-three/drei'

export default function Box() {
const [active, setActive] = useState(0)
// create a common spring that will be used later to interpolate other values
const { spring } = useSpring({
spring: active,
config: { mass: 5, tension: 400, friction: 50, precision: 0.0001 },
})
// interpolate values from commong spring
const scale = spring.to([0, 1], [1, 2])
const rotation = spring.to([0, 1], [0, Math.PI])
const color = active ? spring.to([0, 1], ['#6246ea', '#e45858']) : spring.to([0, 1], ['#620000', '#e40000'])
return (
<Canvas>
<a.mesh
rotation-y={rotation}
scale-x={scale}
scale-z={scale}
onDragOverEnter={() => setActive(1)}
onDragOverLeave={() => setActive(0)}>
<boxBufferGeometry />
<a.meshBasicMaterial color={color} />
</a.mesh>
<OrbitControls />
</Canvas>
)
}
2 changes: 2 additions & 0 deletions example/src/demos/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const Test = { Component: lazy(() => import('./Test')) }
const Viewcube = { Component: lazy(() => import('./Viewcube')) }
const Portals = { Component: lazy(() => import('./Portals')) }
const ViewTracking = { Component: lazy(() => import('./ViewTracking')) }
const FileDragDrop = { Component: lazy(() => import('./FileDragDrop')) }

export {
Animation,
Expand All @@ -50,4 +51,5 @@ export {
MultiView,
Portals,
ViewTracking,
FileDragDrop,
}

0 comments on commit 1b7f27c

Please sign in to comment.