https://htmx.org logo
Join Discord
Powered by
# htmx-general
  • t

    thankful-monkey-57044

    07/20/2020, 8:50 AM
    > So that way, if you're on fast broadband, you get a near instantaneous swap of the heart icon (no loading indicator needed). Otherwise, if you're on a slower connection , the loading indicator will be shown. > @User And this is the rub! 🙂 ..."near instantaneous" is the problem. In my original post I tried to explain... > And I would like to enforce a min 1 sec application of the load state, ...as it otherwise looks very jittery and glitchy when the loading state is flashed for a few ms. > > You can see a cleaned up version of it here, but where I am using Alpine to simulate the network request, and to enforce a small delay that makes it look better. If you wish to witness the problem first-hand, take my 1000ms delay and move it down to 100. So this is the literal definition of a 1st world problem. When the internet is too good, the animation transition looks like garbage. This is what I'm trying to fix, just to find some way to keep
    .htmx-request
    applied to my css for a minimum of 1 sec.
  • b

    bright-honey-15993

    07/20/2020, 8:51 AM
    Ah, okay. Have you tried utilising css transitions?
  • t

    thankful-monkey-57044

    07/20/2020, 8:51 AM
    I thought about it... but don't see how.
  • b

    bright-honey-15993

    07/20/2020, 8:52 AM
    Yeah, thinking about it myself now. Perhaps @User might have some ideas once he's online. Sorry I can't be of more help right now.
  • t

    thankful-monkey-57044

    07/20/2020, 8:52 AM
    No worries! Thanks for thinking about it. Maybe something occurs to you later.
  • t

    thankful-monkey-57044

    07/20/2020, 8:52 AM
    Also for the record, a css transition will punish everyone.
  • t

    thankful-monkey-57044

    07/20/2020, 8:53 AM
    Or apply the 1 sec penalty to all connections.
  • b

    bright-honey-15993

    07/20/2020, 8:53 AM
    I'd take a css transition over a JS transition any day.
  • b

    bright-honey-15993

    07/20/2020, 8:53 AM
    > Or apply the 1 sec penalty to all connections. @User Let's try to avoid this 🙂
  • t

    thankful-monkey-57044

    07/20/2020, 8:54 AM
    an ideal solution would start a clock on
    .htmx-request
    and just not "release" it until a min of 1 sec had passed.
  • t

    thankful-monkey-57044

    07/20/2020, 8:55 AM
    then there are no jumps or hiccups ... because the css animation is a circular disc, it is really hard to see how we can time that transition in css while also using
    .htmx-request
  • t

    thankful-monkey-57044

    07/20/2020, 8:55 AM
    But let's see! 🙂
  • b

    bright-honey-15993

    07/20/2020, 8:56 AM
    I just looked at your pen and tbh, I think it looks fine when setting the resolve time to 0
  • m

    mysterious-toddler-20573

    07/20/2020, 3:15 PM
    @User should a user be able to click the like button again during the transition?
  • t

    thankful-monkey-57044

    07/21/2020, 3:13 PM
    > I just looked at your pen and tbh, I think it looks fine when setting the resolve time to 0 @User but the reality is that a fast connection will still show it for a few hundred milliseconds of course 😉
  • t

    thankful-monkey-57044

    07/21/2020, 3:15 PM
    > @User should a user be able to click the like button again during the transition? @User Nope. Under most circumstances it wouldn't even occur to the user to click it a second time within the ~ 1 second it will hopefully take to complete the xhr request.
  • m

    mysterious-toddler-20573

    07/21/2020, 5:29 PM
    OK, so the logic is "animate over 1s or the time of the request, whichever is more"
  • m

    mysterious-toddler-20573

    07/21/2020, 5:29 PM
    Typically there is one animation for the request, and then a finishing animation
  • m

    mysterious-toddler-20573

    07/21/2020, 5:30 PM
    I need to think about how to accomplish this generally
  • m

    mysterious-toddler-20573

    07/21/2020, 5:30 PM
    I'd like for it to be doable w/ pure htmx
  • t

    thankful-monkey-57044

    07/21/2020, 10:21 PM
    > > I'd like for it to be doable w/ pure htmx > @User So would I. 😉
  • m

    most-jelly-15242

    07/21/2020, 11:31 PM
    @User Quick heads up on the namespaced events thing. Alpine JS nows supports the use of a .camel modifier which allows it to listen to htmx events as they are now. There's a PR in Alpine to fix a bug with the modifier which is going to allow this to work:
    x-on:htmx:before-request.camel.window="console.log('Hello!')"
  • b

    big-airline-13935

    07/22/2020, 4:46 PM
    @User Yeah that's an unfortunate shortcoming of Alpine, although it will still be possible to make it work as per this PR. Hyperscript's syntax makes this a non-issue.
    _="on htmx:afterSettle log 'Settled!'"
    https://htmx.org/docs#hyperscript
  • m

    mysterious-toddler-20573

    07/22/2020, 9:20 PM
    I am absolutely jonesing to get back on hyperscript.
  • b

    bright-honey-15993

    07/22/2020, 9:39 PM
    You guys are mixing htmx, Hyperscript and Alpine?! Tbh, at that point, I think I'd rather use React...
  • f

    future-boots-43048

    07/23/2020, 8:45 AM
    Well ... I'm mixing htmx and (Python) dominate to try to make something ... hmm .... let's just call it interesting right now. I'll let you know how I get on.
  • b

    big-airline-13935

    07/23/2020, 2:34 PM
    > You guys are mixing htmx, Hyperscript and Alpine?! Tbh, at that point, I think I'd rather use React... @User htmx + (Hyperscript or Alpine)
  • b

    bright-honey-15993

    07/23/2020, 4:18 PM
    Yeah, I can see that being useful, but Alpine still means lots of JavaScript really
  • b

    big-airline-13935

    07/23/2020, 5:03 PM
    > Yeah, I can see that being useful, but Alpine still means lots of JavaScript really @bright-honey-15993 the way I use Alpine is with html attributes only, although those few times I do need to inline some JS does feel pretty nasty.
  • b

    bright-honey-15993

    07/23/2020, 5:17 PM
    Yeah, I watched some of Jeffrey Way's intro on it, and was like..."why?!"
1...101112...1146Latest