Index: contrib/views_slideshow_singleframe/views_slideshow.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views_slideshow/contrib/views_slideshow_singleframe/Attic/views_slideshow.js,v retrieving revision 1.1.2.1.2.38 diff -u -p -r1.1.2.1.2.38 views_slideshow.js --- contrib/views_slideshow_singleframe/views_slideshow.js 9 Jun 2010 06:13:36 -0000 1.1.2.1.2.38 +++ contrib/views_slideshow_singleframe/views_slideshow.js 26 Jun 2010 07:20:58 -0000 @@ -163,6 +163,21 @@ Drupal.behaviors.viewsSlideshowSingleFra if (settings.start_paused) { viewsSlideshowSingleFramePause(settings); } + + // Pause if hidden. + if (settings.pause_when_hidden) { + $(window).scroll(function() { + // If the slideshow is visible and it is paused then resume. + // otherwise if the slideshow is not visible and it is not paused then + // pause it. + if (viewsSlideshowSingleFrameIsVisible(settings.targetId, settings.amount_allowed_visible) && settings.paused) { + viewsSlideshowSingleFrameResume(settings); + } + else if (!viewsSlideshowSingleFrameIsVisible(settings.targetId, settings.amount_allowed_visible) && !settings.paused) { + viewsSlideshowSingleFramePause(settings); + } + }); + } // Show image count for people who have js enabled. $('#views_slideshow_singleframe_image_count_' + settings.vss_id).show(); @@ -277,3 +292,54 @@ function readCookie(name) { function eraseCookie(name) { createCookie(name,"",-1); } + +/** + * Checks to see if the slide is visible enough. + * elem = element to check. + * amountVisible = amount that should be visible. Either in percent or px. If + * it's not defined then all of the slide must be visible. + * + * Returns true or false + */ +function viewsSlideshowSingleFrameIsVisible(elem, amountVisible) { + // Get the top and bottom of the window; + var docViewTop = $(window).scrollTop(); + var docViewBottom = docViewTop + $(window).height(); + + // Get the top, bottom, and height of the slide; + var elemTop = $(elem).offset().top; + var elemHeight = $(elem).height(); + var elemBottom = elemTop + elemHeight; + + // If there is no amountVisible defined then check to see if the whole slide + // is visible. + if (amountVisible == '') { + return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom) + && (elemBottom <= docViewBottom) && (elemTop >= docViewTop) ); + } + else { + var missing = 0; + + // Find out how much of the slide is missing from the top. + if (elemTop < docViewTop) { + missing += docViewTop - elemTop; + } + + // Find out how much of the slide is missing from the bottom. + if (elemBottom > docViewBottom) { + missing += elemBottom - docViewBottom; + } + + // If user specified a percentage then find out if the current shown percent + // is larger than the allowed percent. + // Otherwise check to see if the amount of px shown is larger than the + // allotted amount. + if (amountVisible.indexOf('%')) { + return (((missing/elemHeight)*100) < (100 - parseInt(amountVisible))); + } + else { + return (missing < (elemHeight-parseInt(amountVisible))); + } + } +} + Index: contrib/views_slideshow_singleframe/views_slideshow_singleframe.views_slideshow.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views_slideshow/contrib/views_slideshow_singleframe/Attic/views_slideshow_singleframe.views_slideshow.inc,v retrieving revision 1.1.2.1.2.24 diff -u -p -r1.1.2.1.2.24 views_slideshow_singleframe.views_slideshow.inc --- contrib/views_slideshow_singleframe/views_slideshow_singleframe.views_slideshow.inc 6 Jun 2010 22:47:45 -0000 1.1.2.1.2.24 +++ contrib/views_slideshow_singleframe/views_slideshow_singleframe.views_slideshow.inc 26 Jun 2010 07:20:58 -0000 @@ -26,6 +26,8 @@ function views_slideshow_singleframe_vie 'random' => array('default' => 0), 'pause' => array('default' => 1), 'pause_on_click' => array('default' => 0), + 'pause_when_hidden' => array('default' => 0), + 'amount_allowed_visible' => array('default' => ''), 'remember_slide' => array('default' => 0), 'remember_slide_days' => array('default' => 1), 'controls' => array('default' => 0), @@ -102,6 +104,21 @@ function views_slideshow_singleframe_vie '#default_value' => $view->options['views_slideshow_singleframe']['pause_on_click'], '#description' => t('Pause when the slide is clicked.'), ); + $form['views_slideshow_singleframe']['pause_when_hidden'] = array( + '#type' => 'checkbox', + '#title' => t('Pause When the Slideshow is Not Visible'), + '#default_value' => $view->options['views_slideshow_singleframe']['pause_when_hidden'], + '#description' => t('When the slideshow is scrolled out of view this will pause the slideshow.'), + ); + $form['views_slideshow_singleframe']['amount_allowed_visible'] = array( + '#type' => 'textfield', + '#title' => t('Amount of Slide Needed to be Shown'), + '#default_value' => $view->options['views_slideshow_singleframe']['amount_allowed_visible'], + '#description' => t('The amount of the slide that needs to be shown to have it rotate. You can set a percentage such as 50% or the height in px such as 250.'), + '#size' => 4, + '#process' => array('views_process_dependency'), + '#dependency' => array('edit-style-options-views-slideshow-singleframe-pause-when-hidden' => array(1)), + ); $form['views_slideshow_singleframe']['remember_slide'] = array( '#type' => 'checkbox', '#title' => t('Start On Last Slide Viewed'), Index: contrib/views_slideshow_thumbnailhover/views_slideshow.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views_slideshow/contrib/views_slideshow_thumbnailhover/Attic/views_slideshow.js,v retrieving revision 1.1.2.2.2.34 diff -u -p -r1.1.2.2.2.34 views_slideshow.js --- contrib/views_slideshow_thumbnailhover/views_slideshow.js 17 Jun 2010 03:18:02 -0000 1.1.2.2.2.34 +++ contrib/views_slideshow_thumbnailhover/views_slideshow.js 26 Jun 2010 07:20:58 -0000 @@ -148,6 +148,21 @@ Drupal.behaviors.viewsSlideshowThumbnail if (settings.start_paused) { viewsSlideshowThumbnailHoverPause(settings); } + + // Pause if hidden. + if (settings.pause_when_hidden) { + $(window).scroll(function() { + // If the slideshow is visible and it is paused then resume. + // otherwise if the slideshow is not visible and it is not paused then + // pause it. + if (viewsSlideshowThumbnailHoverIsVisible(settings.targetId, settings.amount_allowed_visible) && settings.paused) { + viewsSlideshowThumbnailHoverResume(settings); + } + else if (!viewsSlideshowThumbnailHoverIsVisible(settings.targetId, settings.amount_allowed_visible) && !settings.paused) { + viewsSlideshowThumbnailHoverPause(settings); + } + }); + } // Show image count for people who have js enabled. $('#views_slideshow_thumbnailhover_image_count_' + settings.vss_id).show(); @@ -267,3 +282,52 @@ function eraseCookie(name) { createCookie(name,"",-1); } +/** + * Checks to see if the slide is visible enough. + * elem = element to check. + * amountVisible = amount that should be visible. Either in percent or px. If + * it's not defined then all of the slide must be visible. + * + * Returns true or false + */ +function viewsSlideshowThumbnailHoverIsVisible(elem, amountVisible) { + // Get the top and bottom of the window; + var docViewTop = $(window).scrollTop(); + var docViewBottom = docViewTop + $(window).height(); + + // Get the top, bottom, and height of the slide; + var elemTop = $(elem).offset().top; + var elemHeight = $(elem).height(); + var elemBottom = elemTop + elemHeight; + + // If there is no amountVisible defined then check to see if the whole slide + // is visible. + if (amountVisible == '') { + return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom) + && (elemBottom <= docViewBottom) && (elemTop >= docViewTop) ); + } + else { + var missing = 0; + + // Find out how much of the slide is missing from the top. + if (elemTop < docViewTop) { + missing += docViewTop - elemTop; + } + + // Find out how much of the slide is missing from the bottom. + if (elemBottom > docViewBottom) { + missing += elemBottom - docViewBottom; + } + + // If user specified a percentage then find out if the current shown percent + // is larger than the allowed percent. + // Otherwise check to see if the amount of px shown is larger than the + // allotted amount. + if (amountVisible.indexOf('%')) { + return (((missing/elemHeight)*100) < (100 - parseInt(amountVisible))); + } + else { + return (missing < (elemHeight-parseInt(amountVisible))); + } + } +} Index: contrib/views_slideshow_thumbnailhover/views_slideshow_thumbnailhover.views_slideshow.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views_slideshow/contrib/views_slideshow_thumbnailhover/Attic/views_slideshow_thumbnailhover.views_slideshow.inc,v retrieving revision 1.1.2.1.2.24 diff -u -p -r1.1.2.1.2.24 views_slideshow_thumbnailhover.views_slideshow.inc --- contrib/views_slideshow_thumbnailhover/views_slideshow_thumbnailhover.views_slideshow.inc 6 Jun 2010 22:47:45 -0000 1.1.2.1.2.24 +++ contrib/views_slideshow_thumbnailhover/views_slideshow_thumbnailhover.views_slideshow.inc 26 Jun 2010 07:20:58 -0000 @@ -32,6 +32,8 @@ function views_slideshow_thumbnailhover_ 'random' => array('default' => 0), 'pause' => array('default' => 1), 'pause_on_click' => array('default' => 0), + 'pause_when_hidden' => array('default' => 0), + 'amount_allowed_visible' => array('default' => ''), 'remember_slide' => array('default' => 0), 'remember_slide_days' => array('default' => 1), 'pager_event' => array('default' => 'hover'), @@ -158,6 +160,21 @@ function views_slideshow_thumbnailhover_ '#default_value' => $view->options['views_slideshow_thumbnailhover']['pause_on_click'], '#description' => t('Pause when the slide is clicked.'), ); + $form['views_slideshow_thumbnailhover']['pause_when_hidden'] = array( + '#type' => 'checkbox', + '#title' => t('Pause When the Slideshow is Not Visible'), + '#default_value' => $view->options['views_slideshow_thumbnailhover']['pause_when_hidden'], + '#description' => t('When the slideshow is scrolled out of view this will pause the slideshow.'), + ); + $form['views_slideshow_thumbnailhover']['amount_allowed_visible'] = array( + '#type' => 'textfield', + '#title' => t('Amount of Slide Needed to be Shown'), + '#default_value' => $view->options['views_slideshow_thumbnailhover']['amount_allowed_visible'], + '#description' => t('The amount of the slide that needs to be shown to have it rotate. You can set a percentage such as 50% or the height in px such as 250.'), + '#size' => 4, + '#process' => array('views_process_dependency'), + '#dependency' => array('edit-style-options-views-slideshow-thumbnailhover-pause-when-hidden' => array(1)), + ); $form['views_slideshow_thumbnailhover']['remember_slide'] = array( '#type' => 'checkbox', '#title' => t('Start On Last Slide Viewed'),