defer ping animation
This commit is contained in:
@@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
|
||||||
|
let timeoutId = 0
|
||||||
|
const DelayedPingAnimation = ({isLoading: isLoading}: {isLoading: boolean}) => {
|
||||||
|
const [showLoading, setShowLoading] = React.useState(false)
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (!isLoading && showLoading) {
|
||||||
|
setShowLoading(isLoading)
|
||||||
|
clearTimeout(timeoutId)
|
||||||
|
} else if (isLoading && !showLoading) {
|
||||||
|
timeoutId = setTimeout(() => {
|
||||||
|
setShowLoading(isLoading)
|
||||||
|
console.log('setloading')
|
||||||
|
}, 300) as unknown as number
|
||||||
|
} else if (!isLoading) {
|
||||||
|
setShowLoading(isLoading)
|
||||||
|
clearTimeout(timeoutId)
|
||||||
|
}
|
||||||
|
}, [isLoading])
|
||||||
|
|
||||||
|
if (showLoading && isLoading) return (
|
||||||
|
<div className="inset-0 absolute flex items-center justify-center">
|
||||||
|
<div className="h-16 w-16 bg-pink-600 rounded-full animate-ping"></div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DelayedPingAnimation
|
||||||
@@ -7,6 +7,7 @@ import { requestRender } from 'src/helpers/hooks/useIdeState'
|
|||||||
import texture from './dullFrontLitMetal.png'
|
import texture from './dullFrontLitMetal.png'
|
||||||
import { TextureLoader } from 'three/src/loaders/TextureLoader'
|
import { TextureLoader } from 'three/src/loaders/TextureLoader'
|
||||||
import Customizer from 'src/components/Customizer/Customizer'
|
import Customizer from 'src/components/Customizer/Customizer'
|
||||||
|
import DelayedPingAnimation from 'src/components/DelayedPingAnimation/DelayedPingAnimation'
|
||||||
|
|
||||||
const loader = new TextureLoader()
|
const loader = new TextureLoader()
|
||||||
const colorMap = loader.load(texture)
|
const colorMap = loader.load(texture)
|
||||||
@@ -240,11 +241,7 @@ const IdeViewer = ({ Loading }) => {
|
|||||||
/>
|
/>
|
||||||
</Canvas>
|
</Canvas>
|
||||||
</div>
|
</div>
|
||||||
{state.isLoading && (
|
<DelayedPingAnimation isLoading={state.isLoading} />
|
||||||
<div className="inset-0 absolute flex items-center justify-center">
|
|
||||||
<div className="h-16 w-16 bg-pink-600 rounded-full animate-ping"></div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<Customizer />
|
<Customizer />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -175,6 +175,7 @@ export const useIdeState = (): [State, (actionOrThunk: any) => any] => {
|
|||||||
case 'updateCode':
|
case 'updateCode':
|
||||||
return { ...state, code: payload }
|
return { ...state, code: payload }
|
||||||
case 'healthyRender':
|
case 'healthyRender':
|
||||||
|
const currentParameters = (payload.currentParameters && Object.keys(payload.currentParameters).length) ? payload.currentParameters : state.currentParameters
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
objectData: {
|
objectData: {
|
||||||
@@ -183,7 +184,7 @@ export const useIdeState = (): [State, (actionOrThunk: any) => any] => {
|
|||||||
data: payload.objectData?.data,
|
data: payload.objectData?.data,
|
||||||
},
|
},
|
||||||
customizerParams: payload.customizerParams || state.customizerParams,
|
customizerParams: payload.customizerParams || state.customizerParams,
|
||||||
currentParameters: Object.keys(payload.currentParameters).length ? payload.currentParameters : state.currentParameters,
|
currentParameters,
|
||||||
consoleMessages: payload.message
|
consoleMessages: payload.message
|
||||||
? [...state.consoleMessages, payload.message]
|
? [...state.consoleMessages, payload.message]
|
||||||
: payload.message,
|
: payload.message,
|
||||||
|
|||||||
Reference in New Issue
Block a user