Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

All comments

  • Segni Adeba• 190

    @SegniAdebaGodsSon

    Posted

    Check out this video, https://www.youtube.com/watch?v=jfYWwQrtzzY. Not too much code, utilizes DOM events including different 'drag' events and cursor position event to place these draggable items into the preferred position.

    0
  • Manuel Gil• 340

    @ManuGil22

    Submitted

    I've added a rotation animation to the dice just to 'wait' those 2 secs api takes. However, if u click it again before that timeout ends, it gets kinda bugged.

    Is there something i can do to make it better? not allowing users to click it again during those 2 secs or smth like that?

    Any feedback will be appreciated! :D

    Segni Adeba• 190

    @SegniAdebaGodsSon

    Posted

    Looking good, I got around multiple clicks/fetches by adding a loading state for the fetch API in JS so that while it's in the loading state I made the dice button disabled to click. I used something like this:

    const useFetchAdvice = (url: string, rerun: boolean) => {
        const [advice, setAdvice] = useState<state>({
            data: null,
            loading: true,
            error: null
        });
    
        useEffect(() => {
            setAdvice({
                data: null,
                loading: true,
                error: null
            });
    
            fetch(url)
            .then(res => res.json())
            .then(dat => setAdvice({
                data: dat,
                loading: false,
                error: null
            }))
            .catch(err => setAdvice({
                data: null,
                loading: false,
                error: err
            }))
        }, [...])
    
    }
    
    2