Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery更改水平旋转木马中的图像宽度_Jquery - Fatal编程技术网

Jquery更改水平旋转木马中的图像宽度

Jquery更改水平旋转木马中的图像宽度,jquery,Jquery,我正在尝试将图像转盘更改为其中一个图像的宽度为500px,其余的宽度为100px,示例如下所示: 只有在DIV的中间,滑动或不滑动的图像应该有500个像素。图像应该改变,因为它是在中间的div。例如,如果你给ID 1/7的列表,中间的一个改变大小,如果它是ID 1或其他的< /P> $(document).ready(function() { var EASING = 0.05, FPS = 60, $paneTarget = $('#scroll'), $paneC

我正在尝试将图像转盘更改为其中一个图像的宽度为500px,其余的宽度为100px,示例如下所示:

<>只有在DIV的中间,滑动或不滑动的图像应该有500个像素。图像应该改变,因为它是在中间的div。例如,如果你给ID 1/7的列表,中间的一个改变大小,如果它是ID 1或其他的< /P>
$(document).ready(function() {

var EASING = 0.05,
    FPS = 60,
    $paneTarget = $('#scroll'),
    $paneContainer = $('#scrollContainer'),
    windowWidth = $(window).width(),
    containerWidth = 0,
    maxScroll = 0,
    posX = 0,   // Keep track of the container position with posX
    targetX = 0,
    animInterval = false;   // No interval is set by default

$paneTarget.find('li').each(function() {
    containerWidth += $(this).width();
    $paneContainer.width(containerWidth);
});

// Set maximum amount the container can scroll
// negative because we're gonna scroll to left
maxScroll = -(containerWidth - windowWidth);

// This gets called from the setInterval and handles the animating of the scroll container
function animationLoop() {
    var dx = targetX - posX,    // Difference
        vx = dx * EASING;       // Velocity

    // Add velocity to x position and update css with new position
    posX += vx;
    $paneContainer.css({left: posX});

    // When end target is reached stop the interval
    if (Math.round(posX) === targetX) {
        clearInterval(animInterval);
        animInterval = false;
    }
}

$paneTarget.on('mousemove', function(event) {
    // Calculate the new x position for the scroll container
    targetX = Math.round((event.pageX / windowWidth) * maxScroll);

    // Only start animation interval when it's not already running
    if (!animInterval) {
        animInterval = setInterval(animationLoop, 1000 / FPS);
    }
});

}))

将类添加到您的
  • 节点之一,并更改该类的宽度

    附加HTML

    <li class="special"><img  src="http://www.luxuryselfcatering.uk.com/wp-content/uploads/2013/04/placeholder-1-500x350.jpg" alt="" /></li>
    

    这里是

    谢谢你的回答PioTr.Kaasi-SkySkin,但是这不是我所需要的,图像应该改变,因为它是集中在div的中间。例如,如果你把ID 1/7给列表,中间的一个改变大小,如果它是ID 1或者其他的。
    #scrollContainer li.special {
        width: 500px;
    }