Image scroller 'lagging' when using background-size
Hi,
I am currently building a fullheight thumbnail scroller with thumbnails of 700px. However I want these thumbnails to stretch the full height of the container, hence I want to use this:
- #scroller li.cover a,#scroller li.cover a div{background-position:top center;background-repeat:no-repeat;background-size:cover;}
However this makes the scroller really laggy, you can see it at: my website
When I remove the background-size from the css property, the problem is solved. However I do still want to stretch full background width. How can I solve this? My full jQuery:
- (function($){
- var $container;
- var $containerwidth;
-
- var $startheight;
- var $startwidth;
-
- var $window = $(window);
- var $windowtop;
-
- var $list = $("#scroller ul");
- var $box = $("#scroller li");
- $.fn.outofbounds = function() {
- // define all variables
- $container = $(this);
- $startheight = $(this).height();
- $startwidth = $box.width();
- $windowtop = (($window.height() - $startheight) / 2) * -1;
- // set the width of the scroller really really high
- $container.width(999999);
- // get the actual width
- $containerwidth = $list.width();
- $list.css({"display":"block"});
-
- // when the document is ready
- $(document).ready(function(){
- $box.each(function() {
- var t = $(this);
- var location = t.attr("class");
- t.find("a").css({"background-image":"url(./assets/images/"+location+"/color.jpg)"}).append("<div>").find("div").css({"background-image":"url(./assets/images/"+location+"/grey.jpg)"});
- });
- $box.addClass("cover");
- });
-
- // and everything is loaded
- $window.bind("load", function(){
- // give all boxes a hover effect
- $box.hover(handle_over, handle_out);
- // move over the scroller and see what happens
- $container.bind("mousemove", function(event) {
- mouse_move(event);
- });
- });
- }
-
- function handle_over() {
- $(this).find("div").stop().animate({opacity:0}, 750);
- return false;
- }
-
- function handle_out() {
- $(this).find("div").stop().animate({opacity:1}, 500);
- return false;
- }
-
- function mouse_move(event) {
- if($containerwidth > $window.width()) {
- var mouse_pos = event.pageX;
- var mouse_perc = mouse_pos / ($window.width());
- var dest = -(($containerwidth - $window.width()) * mouse_perc);
- $container.stop().animate({left:dest}, 400, "linear");
- } else {
- $container.css("left",0);
- }
- return false;
- }
- })(jQuery);
What am I doing wrong? Pleas beware I'm a designer, not a high tech technician
Thank you,
Maarten