(jQuery) Problème scrollTo

Problème scrollTo (jQuery) - HTML/CSS - Programmation

Marsh Posté le 08-02-2012 à 15:13:44    

Salut, je souhaiterais utiliser le plugin jquery scrollTo dont vous verrez ma version de travail ici : http://adulte-adulte.fr/GM
Je n'appel le plugin que par le lien "collection" pour l'instant et je souhaiterais donc accéder à la div en question par un sroll.
 
 
Voici les scripts installés dans le head :  
 

Code :
  1. <script type="text/javascript" src="scripts/lib/jquery-1.4.2.min.js"></script>
  2. <script type="text/javascript" src="scripts/jquery.scrollTo-1.4.2-min.js"></script>
  3. <script type='text/javascript' src='scripts/init.js'></script>
  4. <script type="text/javascript">
  5. jQuery(function( $ ){
  6. var $paneTarget = $('#pane-target');
  7. $('#dom-element').click(function(){
  8.  var target = $paneTarget.find('ul').get(0).childNodes[20];
  9.  $paneTarget.stop().scrollTo( target, 800 );
  10. });
  11. $.easing.elasout = function(x, t, b, c, d) {
  12.  var s=1.70158;var p=0;var a=c;
  13.  if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
  14.  if (a < Math.abs(c)) { a=c; var s=p/4; }
  15.  else var s = p/(2*Math.PI) * Math.asin (c/a);
  16.  return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
  17. };
  18. $('#absolute-position-hash').click(function(){
  19.  $paneTarget.stop().scrollTo( {top:'5808px',left:'2648px'}, 800 );
  20. });
  21. $('div.pane').scrollTo( 0 );
  22. // Reset the screen to (0,0)
  23. $.scrollTo( 0 );
  24.  });
  25. </script>


 
 
Puis le lien en question dans le body :
 

Code :
  1. <a href="#COLLECTION" id="absolute-position-hash">C O L L E C T I O N</a>


 
Si quelqu'un pouvais trouver le temps de voir ce qui cloche là dedans ca me rendrait un grand service.
Merci
 

Reply

Marsh Posté le 08-02-2012 à 15:13:44   

Reply

Marsh Posté le 08-02-2012 à 16:52:31    

Salut, je souhaiterais utiliser le plugin jquery scrollTo DANS UN SITE* dont vous verrez ma version de travail ici : http://adulte-adulte.fr/GM

Reply

Marsh Posté le 08-02-2012 à 18:14:52    

Pour ceux que ca intéresse j'ai trouvé la solution ici :  
http://www.codingforums.com/showthread.php?t=149305
 
 
 
 (en anglais désolé)
 
 >> Hi, i just registered because I was having the same problem and wanted to give from what I've experienced. The creator has made a beautiful plugin, but does in fact do a lousy job explaining how to implement it.  
 
 Here's what you need to do in order to get this to work. I am going to dumb down and retardify this step by step on how to use it. Obviously, the name of the files and links are going to vary, so do not copy and paste them verbatim:
 
 1. Append the scrollTo script to your html like what NancyJ has mentioned. Make sure to place it in the head of your html.
 
 example:
 
 <head>
 <script src="js/jquery.scrollTo-1.4.0-min.js" type="text/javascript"></script>
 </head>
 
 2. Make sure you've downloaded the latest version of jquery and append it to your html's head as well (you should have already done this seeing how scrollTo is an jquery plugin).
 
 <head>
 <script src="js/jquery-1.2.6.min.js" type="text/javascript"></script>
 <script src="js/jquery.scrollTo-1.4.0-min.js" type="text/javascript"></script>
 </head>
 
 By doing this, from my basic understanding, this is how you make your html read an external javascript file and work with it.  
 
 3. Now, with that out of the way, all you need to do in order to make this work is to use an href link in your anchor, and link it to the '#' sign, give it a label, and then close it:
 
 <a href="#">label</a>
 
 4. There appears to be three portions to this command. As NancyJ has mentioned, you are going have to apply this command to the onclick parameter of your anchor link. The first part is going to be your destination. For this example, my destination is going to be a div with an id (hence the '#' before the name) I have named destination. The second part is going to be the amount of time, I believe which is in milliseconds (I'm using 800). The third part is optional, and determines what type of easing animation you want to apply to your transition. I am using the Elastic Ease out (elasout).  
 
 <a href="#" onclick="$.scrollTo( '#education', 800, {easing:'elasout'} );">label</a>
 
 And that's it. The plugin does the rest. With this link, my browser should scroll to the div I have named 'destination.' There are other ways you can use this, but I like to have them jump straight to my divs. Obviously, you want to give some spacing and give a distance between your link and your destination.  
 
 Hopefully, I have dumbed this down enough to a remedial level to make sense to those who have no idea what they're doing. I, too consider myself a dummy. I would like to believe that I am more artistic individual than a math/programming genius. So, I can feel your pain.
 
 I've tried the plugin without NancyJ's add-on script and it appears to be working okay without it. However, I do believe her add-on script does smooths out the animation a bit. Anyway, hope this helps and good luck.  
 
 
 Bonne continuation

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed