Linktipp: Howto: JQuery jcarousel Pause bei Hover

So einfach kann jcarousel um eine Hover-Pause ergänzt werden!

Großartiger Code-Schnippsel!

Hier noch einmal kopiert, falls die URL irgendwann nicht mehr erreichbar ist:

  1. jQuery(document).ready(function() {
  2.         jQuery('#mycarousel').jcarousel({
  3.             scroll: 1,
  4.             auto: 2,
  5.             wrap: 'last',
  6.             initCallback: function(jc, state) {
  7.               if (state == 'init') {
  8.                   /* Pause carousel scrolling when a user mouses overs
  9. an item and restart the scrolling when they mouse out.
  10.                    * Written by cormac at finisco dot com 19/2/2009
  11. based on work by Jeremy Mikola:
  12.                    * <a href="http://groups.google.com/group/jquery-en/browse_thread/thread/f550b94...<br />
  13. " title="http://groups.google.com/group/jquery-en/browse_thread/thread/f550b94...<br />
  14. ">http://groups.google.com/group/jquery-en/browse_thread/thread/f550b94...<br />
  15. </a>                   */
  16.                 jc.startAutoOrig = jc.startAuto;
  17.                 jc.startAuto = function() {
  18.                   if (!jc.paused) {
  19.                     jc.startAutoOrig();
  20.                   }
  21.                 }
  22.                 jc.pause = function() {
  23.                   jc.paused = true;
  24.                   jc.stopAuto();
  25.                 };
  26.                 jc.play = function() {
  27.                   jc.paused = false;
  28.                   jc.startAuto();
  29.                 };
  30.                 $('li.jcarousel-item').mouseover(function() {
  31.                     jc.pause();
  32.                 });
  33.                 $('li.jcarousel-item').mouseout(function() {
  34.                     jc.play();
  35.                 });
  36.               }
  37.               jc.play();
  38.             }
  39.         });
  40.     });

Einordnung:

Comments

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Internal paths in single or double quotes, written as "internal:node/99", for example, are replaced with the appropriate absolute URL or path. Paths to files in single or double quotes, written as "files:somefile.ext", for example, are replaced with the appropriate URL that can be used to download the file.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><blockquote>
  • Lines and paragraphs break automatically.
  • Pairs of<blockquote> tags will be styled as a block that indicates a quotation.
  • You can enable syntax highlighting of source code with the following tags: <c>, <cpp>, <css>, <drupal5>, <drupal6>, <java>, <javascript>, <mysql>, <php>, <python>, <ruby>, <smarty>, <xml>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Textual smileys will be replaced with graphical ones.
  • Each email address will be obfuscated in a human readable fashion or (if JavaScript is enabled) replaced with a spamproof clickable link.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.