我一直在为此苦苦挣扎,在文档中找不到解决方案。AnySlider 正在根据需要创建缩略图,但它们不会移动。它们似乎已修复,仅显示 9 个缩略图。问题是当我添加超过 9 张照片时,缩略图会堆叠在下一行,而不是添加到当前并隐藏。
这是我正在使用的代码:
$('#slider1')
.anythingSlider({
navigationFormatter : function(i, panel){ // add thumbnails as navigation links
return '<img src="images/thumbs' + ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19',][i - 1] + '.jpg">';
},
// Callback when the plugin finished initializing
onInitialized: function(e, slider) {
var time = 1000, // allow movement if < 1000 ms (1 sec)
range = 50, // swipe movement of 50 pixels triggers the slider
x = 0, t = 0, touch = "ontouchend" in document,
st = (touch) ? 'touchstart' : 'mousedown',
mv = (touch) ? 'touchmove' : 'mousemove',
en = (touch) ? 'touchend' : 'mouseup';
slider.$window.add( slider.$controls )
.bind(st, function(e){
// prevent image drag (Firefox)
e.preventDefault();
t = (new Date()).getTime();
x = e.originalEvent.touches ? e.originalEvent.touches[0].pageX : e.pageX;
})
.bind(en, function(e){
t = 0; x = 0;
})
.bind(mv, function(e){
e.preventDefault();
var newx = e.originalEvent.touches ? e.originalEvent.touches[0].pageX : e.pageX,
r = (x === 0) ? 0 : Math.abs(newx - x),
// allow if movement < 1 sec
ct = (new Date()).getTime();
if (t !== 0 && ct - t < time && r > range) {
if (newx < x) {
if ($(this).hasClass('anythingControls')) {
slider.$controls.find('.next').trigger('click');
} else {
slider.goForward();
}
return false;
}
if (newx > x) {
if ($(this).hasClass('anythingControls')) {
slider.$controls.find('.prev').trigger('click');
} else {
slider.goBack();
}
}
t = 0; x = 0;
return false;
}
});
}
});});});
知道此配置可能有什么问题吗?提前致谢!