2013-05-07 127 views
0

對不起,問一個很常見的問題,但我找不到如何解決這個問題的任何地方,我不知道這個幻燈片如何工作。我如何在幻燈片放映暫停鼠標懸停

我希望幻燈片在mouseover上暫停並繼續在mouseleave上。

這裏是下面的代碼:

$(function() { 
    $('#carousel').carouFredSel({ 
     width: 800, 
     items: 4, 
     scroll: 1, 
     auto: { 
      duration: 1250, 
      timeoutDuration: 2500  
     }, 
     prev: '#prev', 
     next: '#next', 
     pagination: '#pager', 
    }); 
});` 

而對於塊html代碼:

<!DOCTYPE html> 
<html> 
    <head> 
     <!-- 
      This carousel example is created with jQuery and the carouFredSel-plugin. 
      http://jquery.com 
      http://caroufredsel.dev7studios.com 
     --> 
     <meta http-equiv="content-type" content="text/html;charset=iso-8859-1" /> 
     <meta name="description" value="This beautifull carousel centeres 3 images inside a wrapper with rounded corners. Note that this will not work in Chrome, due to it not being able to overflow content wrapped in rounded corners." /> 
     <meta name="keywords" value="carousel, rounded, corners, jquery, example, pagination" /> 
     <title>Carousel with 3 images centered in rounded corners</title> 
     <script src="http://code.jquery.com/jquery-1.8.2.min.js" type="text/javascript"></script> 
     <script src="jquery.carouFredSel-6.1.0-packed.js" type="text/javascript"></script> 
     <script type="text/javascript" src="try.js"></script> 
     <style type="text/css"> 
      html, body { 
       height: 100%; 
       padding: 0; 
       margin: 0; 
      } 
      body { 
       background-color: #f0f0f0; 
       min-height: 700px; 
      } 
      body * { 
       font-family: Arial, Geneva, SunSans-Regular, sans-serif; 
       font-size: 14px; 
       color: #333; 
       line-height: 22px; 
      } 
      #wrapper { 
       background-color: #fff; 
       border: 1px solid #ccc; 
       border-radius: 100px; 
       width: 800px; 
       height: 127px; 
       padding: 10px; 
       margin: -75px 0 0 -410px; 
       position: absolute; 
       left: 50%; 
       top: 50%; 
      } 
      .caroufredsel_wrapper { 
       border-radius: 90px; 
      } 
      #carousel img { 
       width: 201px; 
       height: 127px; 
       margin: 0 5px; 
       float: left; 
      } 
      #prev, #next { 
       background: transparent url(img/carousel_control.png) no-repeat 0 0; 
       text-indent: -999px; 
       display: block; 
       overflow: hidden; 
       width: 15px; 
       height: 21px; 
       position: absolute; 
       top: 65px; 
      } 
      #prev { 
       background-position: 0 0; 
       left: 30px; 
      } 
      #prev:hover { 
       left: 29px; 
      }    
      #next { 
       background-position: -18px 0; 
       right: 30px; 
      } 
      #next:hover { 
       right: 29px; 
      }     
      #pager { 
       text-align: center; 
       margin: 0 auto; 
       padding-top: 20px; 
      } 
      #pager a { 
       background: transparent url(img/carousel_control.png) no-repeat -2px -32px; 
       text-decoration: none; 
       text-indent: -999px; 
       display: inline-block; 
       overflow: hidden; 
       width: 8px; 
       height: 8px; 
       margin: 0 5px 0 0; 
      } 
      #pager a.selected { 
       background: transparent url(img/carousel_control.png) no-repeat -12px -32px; 
       text-decoration: underline;     
      } 
     </style> 
    </head> 
    <body> 
     <div id="wrapper"> 
      <div id="carousel"> 
       <img src="img/up1.jpg" /> 
       <img src="img/up2.jpg" /> 
       <img src="img/up3.jpg" /> 
       <img src="img/up1.jpg" /> 
       <img src="img/up4.jpg" /> 
       <img src="img/up5.jpg" /> 
       <img src="img/up6.jpg" /> 
      </div> 
      <a id="prev" href="#"></a> 
      <a id="next" href="#"></a> 
      <div id="pager"></div> 
     </div> 
    </body> 
</html> 

,其他兩個js文件是在那些鏈接,你可以去看看。

jquery filesecond jquery file

您可以在頁腳部分看到webmasteroutlet.com當前版本。它不會在鼠標懸停時暫停。

回答

0

你試過這在mouseover?

$("#carousel").mouseover(function() { 
    $("#carousel").trigger('pause' ,true); 
    }); 
+0

感謝它的工作原理,但我不知道如何以及在哪裏[地方這個代碼,我根本不明白這個幻燈片的結構。 – Justin 2013-05-07 21:51:59

+0

更新了我的答案。 – 2013-05-08 05:26:07

2

這裏是我做過什麼,如果有人wnats使用它,我改變滾動元素,就好

scroll: { 
        items: 1, 
        duration: 1250, 
        timeoutDuration: 2500, 
        easing: 'swing', 
        pauseOnHover: 'immediate' 
       }, 
+0

爲什麼-1這個?有用! – 2014-12-01 22:46:05

+0

pauseOnHover:true無效。這解決了它! – skirato 2015-10-22 14:35:24