Jump to content
  • 0

Как сделать слайдер?


Bernard
 Share

Question

4 answers to this question

Recommended Posts

  • 0

вроде этот скрипт отвечает за слайдер там

сам только начал изучать JS, так что сказать что да как там, не могу, пока что)



$(document).ready(function() {
(function($) {
var imgList = [];
$.extend({
preload: function(imgArr, option) {
var setting = $.extend({
init: function(loaded, total) {},
loaded: function(img, loaded, total) {},
loaded_all: function(loaded, total) {}
}, option);
var total = imgArr.length;
var loaded = 0;

setting.init(0, total);
for(var i in imgArr) {
imgList.push($("<img>")
.attr("src", imgArr[i])
.load(function() {
loaded++;
setting.loaded(this, loaded, total);
if(loaded == total) {
setting.loaded_all(loaded, total);
}
})
);
}

}
});
})(jQuery);

var innerWidth = 0;
var dist = 0;
var imgs = new Array();
var duration = $('.slider IMG').size() * 4000;

function sliderGo() {
$('.slider_inner')
.animate({left: '-' + dist}, duration)
.animate({left: '0'}, duration);
}

$('.slider IMG').each(function() {
imgs.push($(this).attr('src'));
});

$(function() {
$.preload(imgs
, {
init: function(loaded, total) {},
loaded: function(img, loaded, total) {},
loaded_all: function(loaded, total) {
$('.slider IMG').each(function() {
innerWidth += $(this).width();
});
$('.slider_inner').width(innerWidth);
dist = innerWidth - $('.slider').width();

sliderGo();
var init = setInterval(sliderGo, duration*2);
}
});
});
});

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy