Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- 2 * Created by IntelliJ IDEA.
- 3 * User: Bugi
- 4 * Date: 13 вер 2010
- 5 * Time: 13:16:06
- 6 * To change this template use File | Settings | File Templates.
- 7 */
- 8var rotate_timer;
- 9jQuery.fn.MainSlider = function()
- 10{
- 11 return this.each(function()
- 12 {
- 13 var conteiner = this;
- 14 var li_width = $('li:first', conteiner).innerWidth();
- 15 if($.browser.webkit)
- 16 {
- 17 // В хроме не может вытянуть ширину дива :(
- 18 li_width = 540;
- 19 }
- 20 var ul_width = $('li', conteiner).length * li_width;
- 21 $('ul', conteiner).css('width', ul_width);
- 22 var isAnimate = false;
- 23 var ul_left = parseInt($('ul',conteiner).css('left'));
- 24
- 25 rotate_slider(5000, conteiner);
- 26
- 27 $('.slide-prev', conteiner).click(function()
- 28 {
- 29 ul_left = parseInt($('ul',conteiner).css('left'));
- 30 if( !(ul_left >= 0) )
- 31 {
- 32
- 33 if(!isAnimate)
- 34 {
- 35 isAnimate = true;
- 36 $('ul', conteiner).animate({ left : ul_left + li_width +'px' } , 1000, '', function()
- 37 {
- 38 isAnimate = false;
- 39 });
- 40 }
- 41 }
- 42 });
- 43
- 44 $('.slide-next', conteiner).click(function()
- 45 {
- 46 clearInterval(rotate_timer);
- 47 ul_left = parseInt($('ul',conteiner).css('left'));
- 48 if(!isAnimate)
- 49 {
- 50 if( (-ul_left + li_width) != ul_width )
- 51 {
- 52 isAnimate = true;
- 53 $('ul', conteiner).animate({ left : ul_left - li_width +'px' } , 1000, '', function()
- 54 {
- 55 isAnimate = false;
- 56 });
- 57 }
- 58 else
- 59 {
- 60 var last_li = $('ul li:last', conteiner).clone();
- 61 $('ul',conteiner).prepend(last_li);
- 62 $('ul',conteiner).css('left', 0);
- 63 ul_left = parseInt($('ul',conteiner).css('left'));
- 64 if(!isAnimate)
- 65 {
- 66 isAnimate = true;
- 67 $('ul', conteiner).animate({ left : ul_left - li_width +'px' } , 1000, '', function()
- 68 {
- 69 last_li.remove();
- 70 $('ul', conteiner).css('left', 0);
- 71 isAnimate = false;
- 72 });
- 73 }
- 74 }
- 75 }
- 76 });
- 77
- 78
- 79 });
- 80}
- 81function rotate_slider(time_out, conteiner)
- 82{
- 83
- 84 rotate_timer = setTimeout(function()
- 85 {
- 86 $('.slide-next', conteiner).click();
- 87 rotate_slider(time_out, conteiner);
- 88 },time_out);
- 89}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement