[solved] Stop Link Navigation

here you will find only solved 1.1 Help topics

Moderator: 1.1 Moderators

[solved] Stop Link Navigation

Postby matze on Fri Jan 09, 2009 5:36 pm

Hi There,

I have a Problem:
I want to do a animation an a website every time the user clicks on a link. The animation sould happen and after it has finished the browser should navigate to the url the link points to.
What I have so far:
  1. function DoClick(url) {
  2.     new Fx.Tween('main').start('height', 100, 0);
  3. }
  4.  
  5. window.addEvent('domready', function(){
  6.     var anilinks = $$('a.animate');
  7.     anilinks.each(
  8.         function(a){
  9.             a.addEvent('click', DoClick.pass(a.href));
  10.             a.onClick = 'return false;';
  11.         }
  12.     );
  13. });

The function DoClick is being called with the url of the link. Now I only need to "stop" the browser, do the animation and then navigate the browser.
How do I stop the browser and, after the Fx.Tween, navigate to the url?

I already asked here: help12/stop-link-navigation-t1006.html but that was the wrong forum.
The solustion there was event.stop(); but this is not possible in v. 1.1...

Thanks and sorry for the bad english!

Matthias
matze
 
Posts: 6
Joined: Thu Jan 08, 2009 5:24 pm

Re: Stop Link Navigation

Postby X-trace on Sat Jan 10, 2009 1:51 pm

  1.  
  2. a.addEvent('click', function(e) {
  3.     var e = new Event(e).stop();
  4.     DoClick.pass(a.href));
  5. }
  6.  
User avatar
X-trace
mootools enthusiast
 
Posts: 399
Joined: Wed Jul 16, 2008 4:23 pm
Location: Groningen, NL

Re: Stop Link Navigation

Postby matze on Mon Jan 12, 2009 10:17 am

Hi There!
Ok that's working really fine!

Now I have another question.
How can I perform the navigation to the URL after the effect has happened?
  1. function DoClick(url) {
  2.     new Fx.Tween('main').start('height', 100, 0);
  3. }

I have to modify this, so far I know. And it has to be with chain and an anonymous function. But I don't know how...

Thanks again!

Matthias
matze
 
Posts: 6
Joined: Thu Jan 08, 2009 5:24 pm

Re: Stop Link Navigation

Postby nanomet on Mon Jan 12, 2009 2:13 pm

You can use Fx.Tween events

  1.  
  2. function DoClick(url) {
  3.     new Fx.Tween('main', {
  4.       onStart: function() {
  5.          // what you want when Fx starts
  6.       },
  7.       onComplete: function() {
  8.         // what you want when Fx completed
  9.       }
  10.     }).start('height', 100, 0);
  11. }
  12.  


More information here: http://mootools.net/docs/Fx/Fx.Tween
Playing codes and causing problems: http://nn2luv.com
nanomet
mootools connoisseurs
 
Posts: 40
Joined: Tue Nov 11, 2008 10:31 am

Re: Stop Link Navigation

Postby matze on Mon Jan 12, 2009 2:17 pm

Thanks a lot!
matze
 
Posts: 6
Joined: Thu Jan 08, 2009 5:24 pm


Return to Solutions

Who is online

Users browsing this forum: No registered users and 1 guest