[Plugin: Promotion Slider] browser scroll bug using image width auto – suggested fix
-
Hi,
Firstly, great thanks to Woodent for a great plugin – nicely thought out design, and simple to extend/customise.
however, whilst creating a customised scroller style for a client, intended to ‘stretch’ panel/image size to with browser width, i came across the following problem:
having set styles in /wp-content/plugins/promotion-slider/css to
... .promo_slider_wrapper { margin:10px 0; position:relative; height: auto;} .promo_slider {height:auto; overflow:hidden; position:relative; } .promo_slider img { margin:0; padding:0; width: 100%; height: auto;} .promo_slider .panel { background:url('images/slide.png'); display:none; float:left; overflow:hidden; width:100%; height:100%; } ...
– this allowed my scroller panel and images to stretch to browser width fine, BUT..
when viewing on the front end (in Chrome V15) the height of the current browser position would ‘jag’ and always end up at the top (ish) of the browser window, whenever the contents of the scroller changed.
the problem is caused because in this chosen ‘css’ configuration, the containing div for the panels ‘momentarily’ shrinks to zero (being set to auto), when it is hidden and refreshed. the browser then loses the browseer scroll position and resets it. thus the ‘jag’.
the solution i found is the following::
edit file: /wp-content/plugins/promotion-slider/js/promo_slider.js
around line 165, add the line::sliders.height(currentSlider.innerHeight());
so that the file reads::
... // Assign variables for ease of use var currentItem = jQuery('.panel-' + currentValue, currentSlider); var newItem = jQuery('.panel-' + newValue, currentSlider); var currentSpan = jQuery('.slider_selections span.current', currentSlider); var newSpan = jQuery('.slider_selections span.' + newValue, currentSlider); //mod jrc 111211 - fix broswer scoller jag on css auto-sized images sliders.height(currentSlider.innerHeight()); //end mod jrc 111211 // Add / Remove classes currentItem.removeClass('current'); ...
(my extra line in mod marks ‘mod jrc …’
this will ensure that the div height for the panel_wrapper, never disappears to zero, (ie. is always recalculated to currently available space), hence, no ‘jag’.
ps. i also implemented Woodent’s fix for the JQuery bug in Chrome, causing ‘refresh’ events to ‘clash’/’stack up’ causing multiple images to appear on front end, all at the same time.
the fix for that is::
to add the following into your themes functions.php file::
... /*mod jrc 111211 - fiix for Promotion Slider jquery bug - upgrade jq*/ function myname_jquery_fix(){ if ( !is_admin() ){ wp_deregister_script('jquery'); wp_register_script('jquery', ("https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"), false, '1.7.0'); wp_enqueue_script('jquery'); } } add_action( 'init', 'myname_jquery_fix'); /*mod jrc 111211*/ ...
might be nice to consider including in some future build/release. (seems to work well, though i still have some further cross-browser testing to complete).
hope this is of help to someone.
- The topic ‘[Plugin: Promotion Slider] browser scroll bug using image width auto – suggested fix’ is closed to new replies.