Index: contrib/views_slideshow_cycle/views_slideshow_cycle.views_slideshow.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views_slideshow/contrib/views_slideshow_cycle/Attic/views_slideshow_cycle.views_slideshow.inc,v retrieving revision 1.1.2.17.2.1 diff -u -p -r1.1.2.17.2.1 views_slideshow_cycle.views_slideshow.inc --- contrib/views_slideshow_cycle/views_slideshow_cycle.views_slideshow.inc 31 Dec 2010 08:41:40 -0000 1.1.2.17.2.1 +++ contrib/views_slideshow_cycle/views_slideshow_cycle.views_slideshow.inc 7 Jan 2011 07:35:55 -0000 @@ -38,6 +38,7 @@ function views_slideshow_cycle_views_sli 'nowrap' => array('default' => 0), 'fixed_height' => array('default' => 1), 'items_per_slide' => array('default' => 1), + 'wait_for_image_load' => array('default' => 1), // Internet Explorer Tweaks 'cleartype' => array('default' => 'true'), @@ -292,6 +293,17 @@ function views_slideshow_cycle_views_sli ), ), ); + $form['views_slideshow_cycle']['wait_for_image_load'] = array( + '#type' => 'checkbox', + '#title' => t('Wait for all the slide images to load'), + '#default_value' => $view->options['views_slideshow_cycle']['wait_for_image_load'], + '#description' => t('If selected the slideshow will not start unless all the slide images are loaded. This will fix some issues on IE7/IE8/Chrome/Opera.'), + '#states' => array( + 'visible' => array( + ':input[name="style_options[views_slideshow_cycle][action_advanced]"]' => array('checked' => TRUE), + ), + ), + ); // Internet Explorer Tweaks $form['views_slideshow_cycle']['ie_tweaks'] = array( Index: contrib/views_slideshow_cycle/js/views_slideshow_cycle.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views_slideshow/contrib/views_slideshow_cycle/js/Attic/views_slideshow_cycle.js,v retrieving revision 1.1.2.2.2.2 diff -u -p -r1.1.2.2.2.2 views_slideshow_cycle.js --- contrib/views_slideshow_cycle/js/views_slideshow_cycle.js 1 Jan 2011 01:20:21 -0000 1.1.2.2.2.2 +++ contrib/views_slideshow_cycle/js/views_slideshow_cycle.js 7 Jan 2011 07:35:55 -0000 @@ -234,45 +234,81 @@ } } - - $(settings.targetId).cycle(settings.opts); - - // Start Paused - if (settings.start_paused) { - Drupal.viewsSlideshow.pause(settings.slideshowId, ''); - } - - // Pause if hidden. - if (settings.pause_when_hidden) { - var checkPause = function(settings) { - // 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. - var visible = viewsSlideshowCycleIsVisible(settings.targetId, settings.pause_when_hidden_type, settings.amount_allowed_visible); - if (visible && settings.paused) { - Drupal.viewsSlideshow.play(settings.slideshowId, ''); - } - else if (!visible && !settings.paused) { - Drupal.viewsSlideshow.pause(settings.slideshowId, ''); - } - } - - // Check when scrolled. - $(window).scroll(function() { - checkPause(settings); - }); - - // Check when the window is resized. - $(window).resize(function() { - checkPause(settings); + // If selected wait for the images to be loaded. + // Otherwise just load the slideshow. + if (settings.wait_for_image_load) { + // For IE/Chrome/Opera we need to make sure the images are loaded before + // starting the slideshow. + settings.totalImages = $(settings.targetId + ' img').length; + settings.loadedImages = 0; + + // Add a load event for each image. + $(settings.targetId + ' img').each(function() { + var $imageElement = $(this); + $imageElement.bind('load', function () { + Drupal.viewsSlideshowCycle.imageWait(fullId); + }); + + // Removing the source and adding it again will fire the load event. + var imgSrc = $imageElement.attr('src'); + $imageElement.attr('src', ''); + $imageElement.attr('src', imgSrc); }); } + else { + Drupal.viewsSlideshowCycle.load(fullId); + } }); } }; Drupal.viewsSlideshowCycle = Drupal.viewsSlideshowCycle || {}; + // This checks to see if all the images have been loaded. + // If they have then it starts the slideshow. + Drupal.viewsSlideshowCycle.imageWait = function(fullId) { + if (++Drupal.settings.viewsSlideshowCycle[fullId].loadedImages == Drupal.settings.viewsSlideshowCycle[fullId].totalImages) { + Drupal.viewsSlideshowCycle.load(fullId); + } + } + + // Start the slideshow. + Drupal.viewsSlideshowCycle.load = function (fullId) { + var settings = Drupal.settings.viewsSlideshowCycle[fullId]; + $(settings.targetId).cycle(settings.opts); + + // Start Paused + if (settings.start_paused) { + Drupal.viewsSlideshow.pause(settings.slideshowId, ''); + } + + // Pause if hidden. + if (settings.pause_when_hidden) { + var checkPause = function(settings) { + // 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. + var visible = viewsSlideshowCycleIsVisible(settings.targetId, settings.pause_when_hidden_type, settings.amount_allowed_visible); + if (visible && settings.paused) { + Drupal.viewsSlideshow.play(settings.slideshowId, ''); + } + else if (!visible && !settings.paused) { + Drupal.viewsSlideshow.pause(settings.slideshowId, ''); + } + } + + // Check when scrolled. + $(window).scroll(function() { + checkPause(settings); + }); + + // Check when the window is resized. + $(window).resize(function() { + checkPause(settings); + }); + } + } + Drupal.viewsSlideshowCycle.pause = function (slideshowID) { $('#views_slideshow_cycle_teaser_section_' + slideshowID).cycle('pause'); }