302
morgh
8y

Made a really cool spinning animation on a button that submits a form...

API Call is too fast to see it

setTimeout

Comments
  • 4
    😂
  • 11
    It could seems fast on your network. But in some it doesn't. So it's always cool to have those :p
  • 1
    @pneves hoe does the timeout work? Does it wait always 5 seconds even if the request is available after 1 second?
  • 2
    @SirWindfield It was @morgh work 😃
    But I think that he won't use 5 seconds. Maybe 500ms.
  • 1
    @pneves oh fail 😂 ye 5 is way to long.
  • 1
    is yah using requestAnimationFrame? that could do it for yah. Also start the spinner when doing local validation perfor request gets sent.
  • 1
    Philip is that you?
  • 5
    Lol, been there. Spent half an hour on the animation just to have it flash on screen too fast to see it animate. First time I've been sad that my network connection was fast. 😂
  • 7
    @Swifticus time to use a CDN (content delay network) also known as cloudflare
  • 1
    @pneves Yeah, this is my only concern. Needlessly slowing down the form submit for slow internet users.

    @rozzzly : Thanks for the tip. Havent used that yet, will check it out. And I'm already validating, the form is just small
  • 7
    @morgh you could monitor the duration of the call and if it's less than one second, just set the timeout for the remainder of that second. That way the minimum time they would wait would be 1000ms. If it's a slow connection, they won't wait an additional amount of time, but if it's fast then it would be a smoother transition than something flashing on the screen and them not even realizing what it is.
  • 3
    Wish I had of thought of that for my project *facepalm* 😑
  • 1
    @Swifticus Probably going to do this. Unless I can figure out requestAnimationFrame
  • 3
    Bad bad bad! UX > ego remember that
  • 0
    @morgh let us know how it goes. Didn't know requestAnimationFrame was a thing. Looks useful.
  • 0
    Yeah seems like a dream for me. 😑
  • 7
    @mostlyharmless - my thinking is that a smooth transition is a better UX than a jittery UI. No user will complain about a 1 second delay that includes a loading indicator, but they might complain about something flashing in front of them when they can't tell what it is.
  • 0
    You probably already know this, but this rant is on the DevRant homepage (web view)!
Add Comment