2012-04-21 67 views
-1

我有一個jQuery JavaScript滑塊的問題。破碎的jQuery滑塊

基本上我對這個網站http://crearewebsites.co.uk/victoria/pb-metal-dev/

這就是所謂的可滑動軌道從http://www.zurb.com/playground/orbit-jquery-image-slider採用了滑蓋的一個問題,我試圖尋找他們的文檔等,但沒有幫助那裏。

問題是,當第一次加載頁面時,所有的幻燈片都非常快速地閃爍,然後它在第一張幻燈片上卡住2個週期,然後才能正常工作。

也有一種方法強制它在圖像容器後面,因爲圓角在動畫時應該覆蓋幻燈片。

任何幫助,即使絲毫不勝感激,歡呼!

下面是代碼即時通訊使用調用滑塊:

<script src="js/jquery.orbit-1.2.3.min.js" type="text/javascript"></script> 
<script type="text/javascript"> 
$(window).load(function() { 
    $('#slider').orbit({ 
    'timer': true, 
    'advanceSpeed': 6000,  
    'bullets' : false,   
    'bulletThumbs': false, 
}); 

的HTML

<div id="slider-container"> 
    <div id="slider" class="png-fix"> 
     <img src="Images/energy-efficient-powder-coating-equipment.png" class="png-fix slide-img" alt="PB Metal Finishing Spray Save System" /> 
     <img src="Images/experts-in-powder-coating-equipment.png" class="png-fix slide-img" alt="Experts in Powder Coating Equipment" /> 
     <img src="Images/complete-turnkey-modular-powder-coating-plant-solutions.png" class="png-fix slide-img" alt="Complete modular, turnkey powder coating plant solutions." /> 

認爲這可能是一些JavaScript代碼:


(function(e) { 
     e.fn.orbit = function(a) { 
       a = e.extend({ 
        animation: "horizontal-push", 
        animationSpeed: 600, 
        timer: true, 
        advanceSpeed: 4E3, 
        pauseOnHover: false, 
        startClockOnMouseOut: false, 
        startClockOnMouseOutAfter: 1E3, 
        directionalNav: true, 
        captions: true, 
        captionAnimation: "fade", 
        captionAnimationSpeed: 600, 
        bullets: false, 
        bulletThumbs: false, 
        bulletThumbLocation: "", 
        afterSlideChange: function() {} 
       }, a); 
       return this.each(function() { 
          function t() { 
           if (!a.timer || a.timer == "false") return false; 
           else if (u.is(":hidden")) v = setInterval(function() { 
            o("next") 
           }, a.advanceSpeed); 
           else { 
            r = true; 
            A.removeClass("active"); 
            v = setInterval(function() { 
             var d = "rotate(" + p + "deg)"; 
             p += 2; 
             w.css({ 
              "-webkit-transform": d, 
              "-moz-transform": d, 
              "-o-transform": d 
             }); 
             if (p > 180) { 
              w.addClass("move"); 
              B.addClass("move") 
             } 
             if (p > 360) { 
              w.removeClass("move"); 
              B.removeClass("move"); 
              p = 0; 
              o("next") 
             } 
            }, a.advanceSpeed/180) 
           } 
          } 

          function q() { 
           if (!a.timer || a.timer == "false") return false; 
           else { 
            r = false; 
            clearInterval(v); 
            A.addClass("active") 
           } 
          } 

          function C() { 
           if (!a.captions || a.captions == "false") return false; 
           else { 
            var d = c.eq(b).data("caption"); 
            if (_captionHTML = e(d).html()) { 
             l.attr("id", d).html(_captionHTML); 
             a.captionAnimation == "none" && l.show(); 
             a.captionAnimation == "fade" && l.fadeIn(a.captionAnimationSpeed); 
             a.captionAnimation == "slideOpen" && l.slideDown(a.captionAnimationSpeed) 
            } else { 
             a.captionAnimation == "none" && l.hide(); 
             a.captionAnimation == "fade" && l.fadeOut(a.captionAnimationSpeed); 
             a.captionAnimation == "slideOpen" && l.slideUp(a.captionAnimationSpeed) 
            } 
           } 
          } 

          function D() { 
           if (a.bullets) F.children("li").removeClass("active").eq(b).addClass("active"); 
           else return false 
          } 

          function o(d) { 
           function g() { 
            c.eq(m).css({ 
             "z-index": 1 
            }); 
            x = false; 
            a.afterSlideChange.call(this) 
           } 
           var m = b, 
            h = d; 
           if (m == h) return false; 
           if (c.length == "1") return false; 
           if (!x) { 
            x = true; 
            if (d == "next") { 
             b++; 
             if (b == s) b = 0 
            } else if (d == "prev") { 
             b--; 
             if (b < 0) b = s - 1 
            } else { 
             b = d; 
             if (mb) h = "prev" 
            } 
            D(); 
            c.eq(m).css({ 
             "z-index": 2 
            }); 
            a.animation == "fade" && c.eq(b).css({ 
             opacity: 0, 
             "z-index": 3 
            }).animate({ 
             opacity: 1 
            }, a.animationSpeed, g); 
            if (a.animation == "horizontal-slide") { 
             h == "next" && c.eq(b).css({ 
              left: k, 
              "z-index": 3 
             }).animate({ 
              left: 0 
             }, a.animationSpeed, g); 
             h == "prev" && c.eq(b).css({ 
              left: -k, 
              "z-index": 3 
             }).animate({ 
              left: 0 
             }, a.animationSpeed, g) 
            } 
            if (a.animation == "vertical-slide") { 
             h == "prev" && c.eq(b).css({ 
              top: y, 
              "z-index": 3 
             }).animate({ 
              top: 0 
             }, a.animationSpeed, g); 
             h == "next" && c.eq(b).css({ 
              top: -y, 
              "z-index": 3 
             }).animate({ 
              top: 0 
             }, a.animationSpeed, g) 
            } 
            if (a.animation == "horizontal-push") { 
             if (h == "next") { 
              c.eq(b).css({ 
               left: k, 
               "z-index": 3 
              }).animate({ 
               left: 0 
              }, a.animationSpeed, g); 
              c.eq(m).animate({ 
               left: -k 
              }, a.animationSpeed) 
             } 
             if (h == "prev") { 
              c.eq(b).css({ 
               left: -k, 
               "z-index": 3 
              }).animate({ 
               left: 0 
              }, a.animationSpeed, g); 
              c.eq(m).animate({ 
               left: k 
              }, a.animationSpeed) 
             } 
            } 
            C() 
           } 
          } 
          var b = 0, 
           s = 0, 
           k, y, x, j = e(this).addClass("orbit"), 
           f = j.wrap('').parent(); 
          j.add(k).width("1px").height("1px"); 
          var c = j.children("img, a img, div"); 
          c.each(function() { 
           var d = e(this), 
            g = d.width(); 
           d = d.height(); 
           if (g > j.width()) { 
            j.add(f).width(g); 
            k = j.width() 
           } 
           if (d > j.height()) { 
            j.add(f).height(d); 
            y = j.height() 
           } 
           s++ 
          }); 
          if (c.length == 1) { 
           a.directionalNav = false; 
           a.timer = false; 
           a.bullets = false 
          } 
          c.eq(b).css({ 
           "z-index": 3 
          }).fadeIn(function() { 
           c.css({ 
            display: "block" 
           }) 
          }); 
          if (a.timer) { 
           f.append(''); 
           var u = e("div.timer"), 
            r; 
           if (u.length != 0) { 
            var w = e("div.timer span.rotator"), 
             B = e("div.timer span.mask"), 
             A = e("div.timer span.pause"), 
             p = 0, 
             v; 
            t(); 
            u.click(function() { 
             r ? q() : t() 
            }); 
            if (a.startClockOnMouseOut) { 
             var E; 
             f.mouseleave(function() { 
              E = setTimeout(function() { 
               r || t() 
              }, a.startClockOnMouseOutAfter) 
             }); 
             f.mouseenter(function() { 
              clearTimeout(E) 
             }) 
            } 
           } 
          } 
          a.pauseOnHover && f.mouseenter(function() { 
           q() 
          }); 
          if (a.captions) { 
           f.append(''); 
           var l = f.children(".orbit-caption"); 
           C() 
          } 
          if (a.directionalNav) { 
           if (a.directionalNav == "false") return false; 
           f.append('RightLeft'); 
           var n = f.children("div.slider-nav").children("span.left"), 
            z = f.children("div.slider-nav").children("span.right"); 
           n.click(function() { 
            q(); 
            o("prev") 
           }); 
           z.click(function() { 
            q(); 
            o("next") 
           }) 
          } 
          if (a.bullets) { 
           f.append(''); 
           var F = e("ul.orbit-bullets"); 
           for (i = 0; i "+(i+1)+" 
            ");if(a.bulletThumbs)if(z=c.eq(i).data(" 
            thumb ")){n=e(''+i+" 
            ");n.css({background:" 
            url("+a.bulletThumbLocation+z+") no - repeat "})}e(" 
            ul.orbit - bullets ").append(n);n.data(" 
            index ",i);n.click(function(){q();o(e(this).data(" 
            index "))})}D()}})}})(jQuery); 
+0

後您使用打電話給你的腳本代碼。沒有人想挖掘你的代碼。 – jivetek 2012-04-21 05:25:32

回答

1

我試過一個示例html,它的工作原理沒有小故障。 圖像(我的樣品中)在我宣佈<img />標籤

凡在你的頁面的圖像不渲染該way.Should這與圖像加載/緩存問題的順序呈現?

我試着用firebug/firefox.php進行調試,最後一張圖像先渲染出來。

樣本HTML:

<body> 
    <div id="imgslider"> 
     <img src="http://www.lorempixum.com/898/270/animals" alt="" /> 
     <img src="http://www.lorempixum.com/898/270/city" alt="" /> 
     <img src="http://www.lorempixum.com/898/270/food" alt="" /> 
     <img src="http://www.lorempixum.com/898/270/sports" alt="" /> 
    </div> 
    <pre>Animals -> City -> Food -> Sports</pre> 
    <script type="text/javascript"> 
     $(window).load(
      function(){ 
       $('#imgslider').orbit({ 
      'timer': true, 
      'advanceSpeed': 6000, 
      'bullets' : false, 
      'bulletThumbs': false, 
      });}); 
    </script> 
</body> 
+0

我檢查了我的HTML標記,我非常肯定它的一切都很好,與你唯一的區別是我的腳本標記位於頭部而不是在身體內部,會造成問題嗎? – tangos 2012-04-21 10:21:37

+0

最後,我通常會在整個文檔加載後將我的代碼/腳本放在我想要運行的位置。 1)嘗試將腳本放在最後。 2)爲什麼你需要2個版本的JQuery 1.4.2和1.6.2? 3)嘗試使用更多圖像的滑塊 – 2012-04-21 18:03:14

+0

感謝您繼續嘗試幫助我,我已經嘗試了您所建議的所有步驟,但不幸的是無濟於事。至少我刪除了不必要的jQuery版本;) – tangos 2012-04-21 19:22:41