jCarousel with Mousewheel Plugin

spiffyd - September 24, 2008 - 05:48
Project:jCarousel
Version:6.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

Does anyone know how to configure the jcarousel to allow for scrolling with the mousewheel plugin?
I'm trying to figure out what belongs to NEXTFUNCTION and PREVIOUSFUNCTION...

<?php
   
$(document).ready(function() {   
        
jCarousel mousewheel scrolling
       
$('#DIV')
            .
mousewheel(function(event, delta) {
                if (
delta > 0)
                    $(
'.jcarousel-next-vertical').NEXTFUNCTION;
                else if (
delta < 0)
                    $(
'.jcarousel-prev-vertical').PREVIOUSFUNCTION;
                return
false; // prevent default
       
});
?>

#1

Rob Loach - February 1, 2009 - 06:51
Version:5.x-1.x-dev» 6.x-1.x-dev

Using the Mouse Wheel module, it's something like this:

<?php
mousewheel_add
('#jcarousel', 'CarouselMouseWheel');
?>

.... And then in your custom JavaScript, you would use:

/**
* Called when there is a mouse wheel event on the carousel.
*/
function CarouselMouseWheel(event, delta) {
  if (delta < 0) {
    $('#jcarousel').next();
  }
  else if (delta > 0) {
    $('#jcarousel').prev();
  }
  return false;
}

The MouseWheel module needs backport to 5.

#2

spiffyd - February 2, 2009 - 01:14

Hi Rob, thanks for the documentation!

Hm... so for clarification, where do I place the code...

<?php
mousewheel_add
('#jcarousel', 'CarouselMouseWheel');
?>

any where on my page.tpl.php? As a script or php insert?

#3

Rob Loach - February 2, 2009 - 02:39

In your page.tpl.php....... '#jcarousel' is the ID of the carousel on the page.

#4

spiffyd - February 2, 2009 - 08:11

There's no need to place that mousewheel_add code within ?

#5

Rob Loach - February 3, 2009 - 18:02

Think this could go into core jCarousel module?

#6

silurius - March 3, 2009 - 18:45

Subscribing.

 
 

Drupal is a registered trademark of Dries Buytaert.