1

画像フォトギャラリーを作成しました。

次の前のボタンをクリックすると、上下にスタイリングしました

前と次をクリックするときに並べて表示する必要があります。

こちらがデモです

http://jsfiddle.net/T657N/16/

4

2 に答える 2

2

topパラメータをleftスクリプト内に変更しただけです。

デモはこちら

于 2012-09-13T08:07:14.797 に答える
1

JavaScript の SwapFirstLast() 関数を変更するだけです。

交換

 $(this).animate({ 'top' : direction + $(this).height() + 'px' }, 'slow', function() { //animate the img above/under the gallery (assuming all pictures are equal height)
  $(this).css('z-index', newZindex) //set new z-index
    .animate({ 'top' : '0' }, 'slow', function() { //animate the image back to its original position
      inAnimation = false; //reset the flag
    });
});

 $(this).animate({ 'left' : direction + $(this).height() + 'px' }, 'slow', function() { //animate the img above/under the gallery (assuming all pictures are equal height)
  $(this).css('z-index', newZindex) //set new z-index
    .animate({ 'left' : '0' }, 'slow', function() { //animate the image back to its original position
      inAnimation = false; //reset the flag
    });
});

したがって、最終的にあなたの機能は次のようになります。

function swapFirstLast(isFirst) {
if(inAnimation) return false; //if already swapping pictures just return
else inAnimation = true; //set the flag that we process a image

var processZindex, direction, newZindex, inDeCrease; //change for previous or next image

if(isFirst) { processZindex = z; direction = '-'; newZindex = 1; inDeCrease = 1; } //set variables for "next" action
else { processZindex = 1; direction = ''; newZindex = z; inDeCrease = -1; } //set variables for "previous" action

$('#pictures img').each(function() { //process each image
  if($(this).css('z-index') == processZindex) { //if its the image we need to process
    $(this).animate({ 'left' : direction + $(this).height() + 'px' }, 'slow', function() { //animate the img above/under the gallery (assuming all pictures are equal height)
      $(this).css('z-index', newZindex) //set new z-index
        .animate({ 'left' : '0' }, 'slow', function() { //animate the image back to its original position
          inAnimation = false; //reset the flag
        });
    });
  } else { //not the image we need to process, only in/de-crease z-index
    $(this).animate({ 'top' : '0' }, 'slow', function() { //make sure to wait swapping the z-index when image is above/under the gallery
      $(this).css('z-index', parseInt($(this).css('z-index')) + inDeCrease); //in/de-crease the z-index by one
    });
  }
});

return false; //don't follow the clicked link

}

それがあなたを助けることを願っています。

于 2012-09-13T08:05:57.127 に答える