Any ideas how to implement drag and drop without using any library?
Segni Adeba
@SegniAdebaGodsSonAll comments
- @donchriscorleoneSubmitted over 2 years ago@SegniAdebaGodsSonPosted over 2 years ago
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 - @ManuGil22Submitted over 2 years ago
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
@SegniAdebaGodsSonPosted over 2 years agoLooking 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