• 用mootools开发的轮播图组件


    <div class="image-slider">
        <div class="img-previewer">
            <div id="imgsbox" style="position:relative">
                <?php foreach ($pictures as $key =>$value) :?>
                <a href="<?=$hrefs[$key];?>
                    ">
                    <img src="<?=$pictures[$key];?>" alt="" /></a>
                <?php endforeach;?></div>
        </div>
        <div class="img-gallery">
            <div class="img-desc">
                <h3>
                    <a href="javascript:;" id="imgTitle">
                        <?=$titles[0];?></a>
                </h3>
                <p>
                    <a href="javascript:;" id="imgDescribe">
                        <?=$describe[0];?></a>
                </p>
            </div>
            <div class="image-listing">
                <ul>
                    <?php
                      foreach ($s_pictures as $k=>$v):
                      $sld = $k == 0 ? "selected" : "";
                    ?>
                    <li class="<?=$sld;?>
                        ">
                        <a href="javascript:;">
                            <img src="<?=$v;?>" alt="" /></a>
                    </li>
                    <?php endforeach;?></ul>
            </div>
        </div>
    </div>
    <script type="text/javascript">
     window.addEvent("domready", function() {
         var imgplayer = new Class({
             initialize: function(a) {
                 this.autoPlay = a.autoPlay || false;
                 this.imgbox = a.imgbox;
                 this.imgList = a.imgList;
                 this.duration = a.duration || 500;
                 this.imgWidth = a.imgWidth;
                 this.imgTitle = a.imgTitle;
                 this.imgDescribe = a.imgDescribe;
                 this.timer = null;
                 this.imgbox.setStyle("width", this.imgWidth * 5);
                 this.fx = new Fx.Tween(this.imgbox, {
                     duration: this.duration
                 });
                 this.currentIndex = a.currentIndex || 0;
                 this.li = this.imgList.getElements('li');
                 for (i = 0; i < this.li.length; i++) {
                     this.li[i].addEvents({
                         'mouseenter': this.addCount.pass([i], this),
                         'mouseleave': this.addCount.pass(['go'], this)
                     });
                 }
                 if (this.autoPlay == true) {
                     this.autoPlayer();
                 }
             },
             addCount: function(i) {
                 if ($type(i) == 'number') {
                     $clear(this.timer);
                     this.currentIndex = i;
                     this.fx.cancel().start('left', (this.imgWidth * -this.currentIndex) + "px");
                 } else {
                     this.currentIndex = this.currentIndex > 2 ? 0 : this.currentIndex + 1;
                     this.fx.start('left', (this.imgWidth * -this.currentIndex) + "px");
                     if (this.autoPlay == true && i == "go") {
                         this.autoPlayer();
                     }
                 }
                 this.li.removeClass("selected");
                 this.li[this.currentIndex].addClass("selected");
                 this.imgTitle['o'].set('text', this.imgTitle['data'][this.currentIndex])
                 this.imgDescribe['o'].set('text', this.imgDescribe['data'][this.currentIndex])
             },
             autoPlayer: function() {
                 this.timer = this.addCount.periodical(3000, this);
             }

         })

         var ig = new imgplayer({
             imgbox: $("imgsbox"),
             imgTitle: {
                 'o': $('imgTitle'),
                 "data": <?= json_encode($titles); ?>
             },
             imgDescribe: {
                 'o': $('imgDescribe'),
                 'data': <?= json_encode($describe); ?>
             },
             imgWidth: 950,
             imgList: $$(".image-listing")[0],
             autoPlay: true
         });
     })
    </script>

  • 相关阅读:
    反转链表 16
    CodeForces 701A Cards
    hdu 1087 Super Jumping! Jumping! Jumping!(动态规划)
    hdu 1241 Oil Deposits(水一发,自我的DFS)
    CodeForces 703B(容斥定理)
    poj 1067 取石子游戏(威佐夫博奕(Wythoff Game))
    ACM 马拦过河卒(动态规划)
    hdu 1005 Number Sequence
    51nod 1170 1770 数数字(数学技巧)
    hdu 2160 母猪的故事(睡前随机水一发)(斐波那契数列)
  • 原文地址:https://www.cnblogs.com/fonyer/p/2994882.html
Copyright © 2020-2023  润新知