0

这是 jQuery 的另一个线程和 Chrome 中的位置:D。我读了一些,但我无法找到解决方案。

function sliderCarousel(){

var count = $('#liste2').children().length; // Numbers of Elements in the Slider
var jump = $('#liste2 li:first').outerWidth(true); // Width of a single Element, including Margin(!)
var resultWidth = count * jump; // Width of all Elements in the Slider.
$('#liste2').width(resultWidth); // Sets the width of the ul to the calculated. Because the slider should work with a various number of Elements
                                 // you cant set a default width.
var unseenElementsNumber = Math.round((-1)*(resultWidth - $('#ein').width())/jump) - 1; // calculates the number of Sliderelements, which are hidden
var unseenElementsWidth = unseenElementsNumber * jump; // calculates the widht of unseen elements

    if(unseenElementsNumber >= 0)
    {
        $('#go').click(function() //rotate left
        {
            if(parseInt($('#liste2').css("left").replace("px","")) + 80 <= 0) // needed to prevent "overscrolling"
            {   
                $('#liste2').animate({
                "left": "+="+jump+"",
                }, 500 ); // speed of rotation
            }
        });

        $('#back').click(function() // rotate right
        {
            if(parseInt($('#liste2').css("left").replace("px","")) - 80 >= unseenElementsWidth) // needed to prevent "overscrolling"
            {   
                $('#liste2').animate({
                "left": "-="+jump+"",
                }, 500 ); // speed of rotation
            }
        });

        $('#start').click(function() //Return to start
        {
            $('#liste2').animate({
                "left": "0px",
                }, 500 ); // speed of rotation
        });
    }

}

所以这是我的代码。它适用于 FF,但不适用于 Chrome。有任何想法吗?

4

0 回答 0