Fix for jQuery scroller

  1. // The following example assumes you have:
  2. // * An outer div with id="latestnews-scroll" and CSS overflow: hidden
  3. // * An inner div with id="latestnews-scroll-inner" and CSS position: relative
  4. // * Two <a> tags with id="control-up" and id="control-down"
  5. var scrollSpeed = 500;
  6.  
  7. // Set the front page latest headlines scroller to the top
  8. $("#latestnews-scroll-inner").css({ top: "0" });
  9.  
  10. // Set click handlers so that when the up and down arrows are clicked on the
  11. // front page latest headlines box, the news scrolls.
  12. $("#control-down").mousedown(function() {
  13.   // The CSS top will be something like 50px or 23pt, but we can't be sure
  14.   // what the unit will be, so parseInt() will strip out the text.
  15.   $("#latestnews-scroll-inner").animate({ top: parseInt($("#latestnews-scroll").css("height")) - parseInt($("#latestnews-scroll-inner").css("height")) }, scrollSpeed);
  16.   return false;
  17. });
  18. $("#control-up").mousedown(function() {
  19.   $("#latestnews-scroll-inner").animate({ top: "0" }, scrollSpeed);
  20.   return false;
  21. });
  22. $("#control-up, #control-down").bind("mouseout mouseup", function() {
  23.   $("#latestnews-scroll-inner").stop();
  24.   return false;
  25. });
  26.  
  27. // Disable the default <a> tag behaviour because they're not real links.
  28. $("#control-down, #control-up").click(function() {
  29.   return false;
  30. });

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.