1

私のサイトで画像のスライドショーを使用しています。スライダーにトランジションを追加したいのですが、誰か助けてください...スライダーはここに表示されているものと同じです:http: //yellowandred.in/PGP%20Enterprise/index.php

4

1 に答える 1

1

jquery http://jquery.com/を使用できます

あなたの HTML コード:

<!-- styling the height and width is important for some transitions -->
<div id="slideshow" style="width: 400px; height: 200px">
  <img src="../img/one.jpg"> <!-- can use any element you want, not just images -->
  <img src="../img/two.jpg">
  <img src="../img/three.jpg">
  <img src="../img/four.jpg">
  <img src="../img/five.jpg">
</div>

あなたの Java スクリプト:

var $el = $('#slideshow');
$el.slideshow({
  duration: 400,
  delay: 3000,
  selector: '> img',
  transition: 'push(up)',
  autoPlay: true,
  show: function (params){
    var nextIndex = params.next.index;
    if (nextIndex > 2) {
      // do something awesome when the slide is after the third slide.
    }
  },
  complete: function (params){
    // do something awesome when a transition finishes
  }
});

// get the slideshow object if you want it
var slideshow = $el.data('slideshow');

// show the third slide
$el.slideshow( 'show', 2 ); // Element API
slideshow.show(2); // object API

// show the next slide
slideshow.show('next');

// pause and play
slideshow.stop();
slideshow.play();

カスタムトランジション:

jQuery.rf.slideshow.defineTransition('slide', function (params, dir, ease){
  var animation = {},
      prop = (dir == 'left' || dir == 'right') ? 'left' : 'top';
  animation[prop] = (dir == 'left' || dir == 'up') ? '-100%' : '100%';
  params.previous.animate(animation, params.duration, ease);
});

独自のトランジションを作成することもできます;)

于 2012-07-29T05:04:04.257 に答える