$options['visible'] = array('default' => NULL);
$options['scroll'] = array('default' => '');
$options['auto'] = array('default' => 0);
+ $options['autoPause'] = array('default' => '1');
$options['animation'] = array('default' => '');
$options['start'] = array('default' => '1');
$options['easing'] = array('default' => NULL);
'#options' => $range,
'#default_value' => $this->options['start'],
);
+ $form['advanced']['autoPause'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Pause auto-scroll on hover'),
+ '#description' => t('If auto-scrolling, pause the carousel when the user hovers the mouse over an item.'),
+ '#default_value' => $this->options['autoPause'],
+ );
$form['advanced']['vertical'] = array(
'#type' => 'checkbox',
'#title' => t('Vertical'),
var options = settings.jcarousel.carousels[key];
// Add standard options required for AJAX functionality.
- if (options.ajax) {
+ if (options.ajax && !options.itemLoadCallback) {
options.itemLoadCallback = Drupal.jcarousel.ajaxLoadCallback;
}
+ // If auto-scrolling, pause animation when hoving over the carousel.
+ if (options.auto && options.autoPause && !options.initCallback) {
+ options.initCallback = function(carousel, state) {
+ Drupal.jcarousel.autoPauseCallback(carousel, state);
+ }
+ }
+
// Change next and previous buttons to links for accessibility.
if (!options.buttonNextHTML && !options.buttonPrevHTML) {
options.buttonNextHTML = '<a href="javascript:void(0)"></a>';
};
/**
- * AJAX Callback for all jCarousel-style views.
+ * Init callback for jCarousel. Pauses the carousel when hovering over.
+ */
+Drupal.jcarousel.autoPauseCallback = function(carousel, state) {
+ function pauseAuto() {
+ carousel.stopAuto();
+ }
+ function resumeAuto() {
+ carousel.startAuto();
+ }
+ carousel.clip.hover(pauseAuto, resumeAuto);
+};
+
+/**
+ * AJAX callback for all jCarousel-style views.
*/
Drupal.jcarousel.ajaxResponseCallback = function(jcarousel, target, response) {
if (response.debug) {
}
alert(Drupal.t("An error occurred at @path.\n\nError Description: @error", {'@path': path, '@error': error_text}));
-}
+};
})(jQuery);