8
The idea is to start an animation when a hash is found in the URL.
Example
Taking the example of a page whose navigation works by hashing:
<nav>
<ul>
<li><a href="#john">John</a></li>
<li><a href="#doe">Doe</a></li>
<li><a href="#Jane">Jane</a></li>
</ul>
</nav>
<section id="john">Super BuBu</section>
<section id="doe">Super Saiyan</section>
<section id="jane">Jane Porter</section>
The user clicks on the menu and the page scrolls to the id
in question.
The idea is to trigger an action when for example access to #doe
that could be accomplished through the event click on the link with the href
equal to #doe
.
Problem
If the user goes directly to the page through a URL that already contains the hash to direct it to the correct section, the action previously associated with clicking on the mentioned element is not triggered.
http://www.meusite.com/bananas.php#doe
Question
How to trigger an action when a particular hash is found in the browser URL?
Trigger = fire (think) :)
– Maniero
@bigown Pois, I don’t know ;) But "shoot" or "trigger" are also fine! Although correct, one can change to make more sense to the masses!
– Zuul
Hahaha, sorry, but "trigger" sounds VERY funny in Brazil! Ah, and funny in Brazil means "fun".
– bfavaretto
@bfavaretto I am always learning :) What is the most appropriate word for what I meant they would use there?
– Zuul
I think "shoot", as suggested by the bigown. And I’m happy to learn this new word "trigger", I will use it! We’ll see if anyone understands me :)
– bfavaretto
Thinking of fuze, it makes perfect sense.
– Bacco
I suggest you take a look at the library Sammy.js. It seems promisora, but as I’ve been stalling to learn it for a long time, I still don’t have enough knowledge to post something more concrete as an answer.
– mgibsonbr