我正在使用jquery Tiny Carousel来滑动图像,但是我们的客户要求在同一个方向上连续滚动我搜索了一天而且我找不到确切的东西......有没有人在这里遇到过它?
现在我正在使用tinycarousel的这个插件
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery("#slider").tinycarousel({ axis: 'x', display: 1, interval: true })
});
</script>
并且我发现有了这个循环是不可能有人知道如何循环这个?或者指向另一个滑块jquery控件....
答案 0 :(得分:2)
我这样做
在jquery.tinycarousel.js中搜索函数initialize()并替换
iSteps = Math.max(1, Math.ceil(oPages.length / options.display) - iLeftover);
与
iSteps = 9999999999999999999999999;
或强> 在jquery.tinycarousel.min.js中搜索
u=Math.max(1,Math.ceil(k.length/e.display)-x);
并替换为u = 9999999999999999999999999;
然后
将此代码放入文档准备
$('#slider1').tinycarousel({'display':3});
var SliderLength = $('#slider1 .viewport li').length;//set li or img or what ever
var append = $('#slider1 .viewport > ul').html();//grab the curent items
$('.buttons.next').mouseup(function()
{//next button click event
$('#slider1 ul').append(append);//append those item
var sliderWidth = parseInt($('#slider1 .overview').width());
var curLength = parseInt($('#slider1 li').length);
$('#slider1 .overview').width((sliderWidth * (curLength / SliderLength) ));//update content width
});
答案 1 :(得分:2)
这是demo using the jQuery.carouFredSel-plugin
HTML
<div id="wrapper">
<div id="carousel">
<div>
<img src="img/fruit1.png" alt="fruit1" width="200" height="200" />
<span>Apple</span>
</div>
<div>
<img src="img/fruit2.png" alt="fruit2" width="200" height="200" />
<span>Mandarin</span>
</div>
<div>
<img src="img/fruit3.png" alt="fruit3" width="200" height="200" />
<span>Banannas</span>
</div>
<div>
<img src="img/fruit4.png" alt="fruit4" width="200" height="200" />
<span>Cherries</span>
</div>
<div>
<img src="img/fruit5.png" alt="fruit5" width="200" height="200" />
<span>Orange</span>
</div>
<div>
<img src="img/fruit6.png" alt="fruit6" width="200" height="200" />
<span>Melon</span>
</div>
<div>
<img src="img/fruit7.png" alt="fruit7" width="200" height="200" />
<span>Lemon</span>
</div>
<div>
<img src="img/fruit8.png" alt="fruit8" width="200" height="200" />
<span>Grapes</span>
</div>
<div>
<img src="img/fruit9.png" alt="fruit9" width="200" height="200" />
<span>Peach</span>
</div>
<div>
<img src="img/fruit10.png" alt="fruit10" width="200" height="200" />
<span>Pear</span>
</div>
<div>
<img src="img/fruit11.png" alt="fruit11" width="200" height="200" />
<span>Strawberry</span>
</div>
<div>
<img src="img/fruit12.png" alt="fruit12" width="200" height="200" />
<span>Melon</span>
</div>
</div>
</div>
的JavaScript
$(function() {
var $c = $('#carousel'),
$w = $(window);
$c.carouFredSel({
align: false,
items: 10,
scroll: {
items: 1,
duration: 2000,
timeoutDuration: 0,
easing: 'linear',
pauseOnHover: 'immediate'
}
});
$w.bind('resize.example', function() {
var nw = $w.width();
if (nw < 990) {
nw = 990;
}
$c.width(nw * 3);
$c.parent().width(nw);
}).trigger('resize.example');
});
CSS
html, body {
height: 100%;
padding: 0;
margin: 0;
}
body {
background-color: #eee;
position: relative;
min-height: 300px;
}
body * {
font-family: Arial, Geneva, SunSans-Regular, sans-serif;
font-size: 14px;
color: #333;
line-height: 22px;
}
#wrapper {
background-color: #fff;
border-top: 1px solid #ccc;
width: 100%;
height: 50%;
margin-top: -1px;
position: absolute;
left: 0;
top: 50%;
}
#carousel {
margin-top: -100px;
}
#carousel div {
text-align: center;
width: 200px;
height: 250px;
float: left;
position: relative;
}
#carousel div img {
border: none;
}
#carousel div span {
display: none;
}
#carousel div:hover span {
background-color: #333;
color: #fff;
font-family: Arial, Geneva, SunSans-Regular, sans-serif;
font-size: 14px;
line-height: 22px;
display: inline-block;
width: 100px;
padding: 2px 0;
margin: 0 0 0 -50px;
position: absolute;
bottom: 30px;
left: 50%;
border-radius: 3px;
}
答案 2 :(得分:0)
试试这个
$(function(){
var current = 1;
var totalImages = $("#slider-code li").size();
var oSlider = $('#slider-code').tinycarousel({
animation:false,
controls: false
});
$('#nextButton').click(function(){
current += 1;
if(current > totalImages){
current = 1;
}
oSlider.tinycarousel_move(current);
});
});
中的演示答案 3 :(得分:0)
这就是我在像你这样的情况下编码的内容。这会向上滚动,但您可以轻松修改它以向任何方向滚动。将算法从marginTop修改更改为:
marginLeft减少1,从右到左滚动
(function($)
{
var ScrollMe = function(element)
{
var elem = $(element);
var obj = this;
elem.wrapInner("<div class='mbui_scrollable'></div>");
var scr=elem.children("div.mbui_scrollable");
setInterval($(this).scrollUp,130); //CHANGE HERE FOR SPEED
};
$.fn.scrollme = function()
{
return this.each(function()
{
var element = $(this);
// Return early if this element already has a plugin instance
if (element.data('scrollme')) return;
// pass options to plugin constructor
var myplugin = new ScrollMe(this);
// Store plugin object in this element's data
element.data('scrollme', myplugin);
});
};
$.fn.scrollUp = function(elem)
{
var allObj=$(".mbui_scrollable");
for(i=0;i<allObj.length;i++)
var s=$(allObj[i]).css('marginTop');
var n=parseInt(s)-1; //CHANGE HERE TO CHANGE DIRECTION AND SPEED
var h=$(allObj[i]).css('height');
if((n*-1)>=parseInt(h))
n=$(allObj[i]).parent().css('height');
$(allObj[i]).css('marginTop',n);
};})(jQuery);
适用于以下元素:
$(".scroll").scrollme();
答案 4 :(得分:0)
对于我的iPhone应用程序的网站(niwuzzles.com),我使用了Alen Grakalic的jQuery插件EasySlider来实现这一目标。
项目描述:
http://cssglobe.com/post/5780/easy-slider-17-numeric-navigation-jquery-slider
连续幻灯片演示:
http://cssglobe.com/lab/easyslider1.7/01.html
代码示例:
<head>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/easySlider1.7.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#slider").easySlider({
auto: true,
continuous: true
});
});
</script>
</head>
<body>
<div id="slider">
<ul>
<li><img src="img1.png" /></li>
<li><img src="img2.png" /></li>
<li><img src="img3.png" /></li>
<li><img src="img4.png" /></li>
</ul>
</div>
</body>
答案 5 :(得分:0)
我对Tiny Carousel进行了一些更改以添加循环。我只是从定时滑动功能中获取了一些东西。
答案 6 :(得分:0)
我认为它必须有效
$('#slider1').tinycarousel({start: 2,
interval: true
});
答案 7 :(得分:-1)