jQuery函数在firefox和chrome上工作但不在safari中

时间:2013-11-30 14:43:40

标签: javascript jquery safari

这个jQuery功能可以滑动图像,它在Firefox和Chrome中运行良好,但是我不知道为什么它不能用于safari,我可以只滑动图像一次,然后它被阻止。任何人都可以帮我解决我的问题

slide = function (dir) {
    isAnimating = true;
    var $currentItem = $items.eq(current),
        $currentSlide = $slides.eq(current);

    // update current value
    if (dir === 'next') {
        (current < itemsCount - 1) ? ++current : current = 0;
    } else if (dir === 'prev') {
        (current > 0) ? --current : current = itemsCount - 1;
    }
    // new item that will be shown
    var $newItem = $items.eq(current),
        // new slide that will be shown
        $newSlide = $slides.eq(current);

    // position the new item up or down the viewport depending on the direction
    if ($('#is_pair').size() > 0) {
        if (current == 1) {
            $('#currentImage').html(2);
        }
        if (current == 2) {
            $('#currentImage').html(2);
        }
        if (current == 3) {
            $('#currentImage').html(1);
        }
        if (current == 0) {
            $('#currentImage').html(1);
        }
    } else {
        $('#currentImage').html(current + 1);
    }
    $newItem.css({
        top: (dir === 'next') ? '-100%' : '100%',
        zIndex: 999
    });

    $newSlide.css({
        top: (dir === 'next') ? '100%' : '-100%',
        zIndex: 999
    });

    setTimeout(function () {

        // move the current item and slide to the top or bottom depending on the direction
        $currentItem.addClass('ps-move').css({
            top: (dir === 'next') ? '100%' : '-100%',
            zIndex: 1
        });

        $currentSlide.addClass('ps-move').css({
            top: (dir === 'next') ? '-100%' : '100%',
            zIndex: 1
        });

        // move the new ones to the main viewport
        $newItem.addClass('ps-move').css('top', 0);
        $newSlide.addClass('ps-move').css('top', 0);

        // if no CSS transitions set the isAnimating flag to false
        if (!support) {
            isAnimating = false;
        }
    }, 0);
    // update nav images
    updateNavImages();
};

我认为有些事情在这里失败

// move the new ones to the main viewport
$newItem.addClass('ps-move').css('top', 0);
$newSlide.addClass('ps-move').css('top', 0);

0 个答案:

没有答案