这是一个简单的请求,但谷歌很难做到。以下是要求:
到目前为止,我已经看到了许多幻灯片插件,需要大量复杂的支持html和css。为了让幻灯片插件对它进行转换,构建这个html似乎有点愚蠢。
而且,我不知道这些幻灯片插件背后的代码有多糟糕。天啊!
发布于 2009-09-01 03:34:12
下面是一些我很快就把(还没有测试过的东西--只是一些想法--)放在一起的东西,你也许可以在上面开发。应该不难。
var imgs = ['a.png', 'b.png', 'c.png'];
function Slideshow(img_list, container) {
var self = this;
var $slides = [];
var current = { 'ith': 0, '$slide': null };
function initialize() {
// Create the images
img_list.map(function (i) {
$slides.push($('<img>').attr('src', i).hide().appendTo(container));
});
current.$slide = $slides[0];
current.ith = 0;
// Initialize binds (jquery hotkeys or something)
$(document).bind('keydown', '>', function () {
// Do stuff
self.next();
});
$(document).bind('keydown', '<', function () {
// Do stuff
self.prev();
});
};
this.indexTo = function (i) {
current.$slide.hide();
current.$slide = $slides[i];
current.ith = i;
if (current.$slide ==== undefined) {
if (i < 0) {
current.$slide = $slides[$slides.length - 1];
current.ith = $slides.length - 1;
} else {
current.$slide = $slides[0];
current.ith = 0;
}
}
// Effects or something else
return current.$slide.show();
};
this.next = function () {
return self.indexTo(current.ith++);
};
this.prev = function () {
return self.indexTo(current.ith--);
};
initialize();
};发布于 2009-09-01 03:33:23
发布于 2009-09-01 03:32:13
https://stackoverflow.com/questions/1360354
复制相似问题