-
Notifications
You must be signed in to change notification settings - Fork 858
Conversation
I just noticed that there’s a very brief flash after the click and before the animation. This is true for both Chrome and FF. I imagine it’s because changing the url makes the browser want to skip to that anchor, and then the script comes in and brings it back to where it was as it begins to animate. I’ll look into this some more and work on a solution. |
No jerkiness.
Found a solution. We’re already testing for Solution now uses pushState and no more jerkiness. I’d still like to pursue the |
Turns out there’s a bug that makes Webkit browsers ignore I’m reverting to using the original behavior (update URL after animation) until I can find a better solution, so I’m closing this pull request. |
Hi @agarzola - Sorry for the delayed response on this. As @robertpateii notes in another issue, there are some issues with the URL update and back button behavior in FireFox with the current implementation, so I'll be looking into that a bit more closely. I do like your before, after, and false options idea, though. I'll keep you posted! |
Thanks @cferdinandi! No worries. I’m still looking into something that works for me, and then will report back. For the time being, I’m keeping the update-URL-before-animation behavior and making the following adjustments to the
This changes the location hash to This solution is, of course, very specific to my needs, but I thought I’d share just in case there’s anything in there that sparks any ideas on your end. Thanks again! |
Hey guys, Yeah, to support I'm happy with (But if you must have all 3 options, may I suggest you make them Best, Rob |
@robertpateii - I agree on both points. I think you're right: it should be at the start or not at all. Cheers! |
I would suggest one change to the code in this pull request. Use the pushState line from my commit in #18. We should avoid passing Null is the default state object, so you don't want to re-issue that when you're actually in a different state. And the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history#The_pushState(\).C2.A0method) suggests that the 2nd argument, title, should be set to an empty string because we're not sure how it will be used in the future. so replace this: with this: Would you agree? p.s. |
@agarzola - This has been fixed in version 2.18. Thanks for your help on this! |
Great job, @cferdinandi! Thanks again. |
Also, sorry for not merging your pull request. Because I was juggling this request and #26 at the same time, I ended up updating the code manually. Appreciate your help greatly, though! |
My ego is intact! I’m just happy that I get to use this script. Thank you for sharing it with the world. |
Instead of waiting for the animation to stop before updating the URL, let’s update it right off the bat.
I’m using
nav:target
to show/hide my main menu on touch devices using only CSS. One of the benefits of this is that as soon as a menu item is tapped, the menu is hidden because the URL changes. Enter smooth-scroll: Because the script waits until the animation stops before updating the URL, the menu stays visible while the script animates the scroll to the selected location, and only then closes. This looks awkward.This commit changes the order of things, so that the URL is changed immediately, making my menu toggle at the expected time (immediately after tapping a menu item).
Let me know if you would prefer a more robust solution that offers both options. For example: dataURL could have the values
before
,after
, andfalse
, so developers have more control over this behavior. I’d like to take a crack at that if it’s something you’d like to see.Thanks!