Guest User

Untitled

a guest
May 27th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.77 KB | None | 0 0
  1. ## jquery extension
  2.  
  3. jQuery.fn.extend({ // We want our navigation set up to reveal itself when hovering over the containing div.
  4. // This function is called for each button, to set up this behaviour.
  5. // we extend jQuery like this to allow chaining among other jQuery functions
  6. navSetup: function(arguments,$target) { // we've brought the orientation of the button's hide direction with us
  7. if (!$target) {var $target = $(this)};
  8. var options = { // setting up some options for the animation of the buttons when hovered over
  9. distance: 82, // distance in pixels to move it
  10. show: {
  11. duration: 50,
  12. queue:false // we don't want to wait for other animations to happen first, which will improve responsiveness.
  13. }, // milliseconds to show the button
  14. hide: {
  15. duration: 150,
  16. queue:false // we don't want to wait for other animations to happen first, which will improve responsiveness.
  17. }, // ms to hide the button
  18. mouseover: { // our options for the hoverIntent jQuery plugin
  19. sensitivity: 10, // number = sensitivity threshold (must be 1 or higher)
  20. interval: 80, // number = milliseconds for onMouseOver polling interval
  21. timeout: 160, // number = milliseconds delay before onMouseOut
  22. over: function(){$target.animate(args.show,options.show)},
  23. // when hovering over the button, animate with css argument hash and predefined duration
  24. out: function(){$target.animate(args.hide,options.hide).css('background-position','left')}
  25. // when finished hovering, animate with css argument hash and predefined duration
  26. },
  27. // at the start, the buttons are already presented and we'll want to hide them from view slowly
  28. intro: { // setting up animation options for the nav 'introduction'
  29. duration: 1500 // duration in ms to hide them from view
  30. // easing: 'swing'
  31. }
  32. },
  33. args = setupArgsAltAlt(arguments.due);
  34.  
  35. $(this) // select the button (relative to the called element, as previously defined)
  36. .hover(
  37. function(){
  38. $(this)
  39. .stopTime(this.id)
  40. .hoverIntent(options.mouseover);
  41. },function(){})
  42. .oneTime((arguments.delay),(this.id),function(){
  43. // set up a delay (brought in as an argument earlier) using the timers plugin
  44. // we will wait this amount first, so the user can get a good look.
  45. $(this).hoverIntent(options.mouseover); // use our options to setup the hoverIntent plugin on the called element
  46.  
  47. $target.animate(args.hide,options.intro);
  48. // then animate the hiding of the button
  49. });
  50.  
  51. return $(this); // pass back the called element (for further jQuery chaining).
  52. },
  53. ## jquery function supporting the above
  54.  
  55. function setupArgsAltAlt(o) {
  56. var a = {'show':{},'hide':{}}, s='left';
  57. if (o=='west') {
  58. a.hide[s] = "-36px";
  59. } else {
  60. a.hide[s] = "136px";
  61. };
  62. a.show[s] = "32px";
  63. return a;
  64. }
  65.  
  66. ## jquery document ready
  67.  
  68. // setup scrolling with all buttons contained within the main slideshow and pane navigation
  69. $('#left').navSetup({due:'west',delay:5000},$('#left a')); // setup the animation for the main slideshow navigation buttons
  70. $('#right').navSetup({due:'east',delay:5000},$('#right a')); // each button's containing div is sent to a function along with it's orientation and an initial delay time
  71. $('#top').paneSetup({due:'north',delay:3000},$browser); // this will hide the buttons and allow them to be revealed when hovering
  72. $('#bottom').paneSetup({due:'south',delay:3000},$details); // over the area they are contained within (occupying a large area at the edges)
  73.  
  74.  
  75. ## html
  76.  
  77. <span id="photonav">
  78. <div id="left"><a class="button prev"></a></div>
  79. <div id="center"></div>
  80. <div id="right"><a class="button next"></a></div>
  81. </span>
Add Comment
Please, Sign In to add comment