Showing
1 changed file
with
31 additions
and
31 deletions
@@ -7,6 +7,37 @@ var $ = require('jquery'); | @@ -7,6 +7,37 @@ var $ = require('jquery'); | ||
7 | 7 | ||
8 | (function($) { | 8 | (function($) { |
9 | $.fn.slider2 = function(options) { | 9 | $.fn.slider2 = function(options) { |
10 | + function autoplay(index, limit, toright) { | ||
11 | + if (toright === true) { | ||
12 | + $('.next').trigger('click'); | ||
13 | + if (index === (limit - 3)) { | ||
14 | + autoplayrecycle(--index, limit, false); | ||
15 | + } else { | ||
16 | + autoplayrecycle(++index, limit, true); | ||
17 | + } | ||
18 | + } else { | ||
19 | + $('.prev').trigger('click'); | ||
20 | + if (index === 0) { | ||
21 | + autoplayrecycle(++index, limit, true); | ||
22 | + } else { | ||
23 | + autoplayrecycle(--index, limit, false); | ||
24 | + } | ||
25 | + } | ||
26 | + } | ||
27 | + | ||
28 | + function autoplayrecycle(index, limit, toright) { | ||
29 | + window.setTimeout(autoplay, $.fn.slider2.defaults.delaytime, index, limit, toright); | ||
30 | + } | ||
31 | + | ||
32 | + function changePic(index, width, callback) { | ||
33 | + var offersetleft = -(index * width); | ||
34 | + | ||
35 | + $('.img-list') | ||
36 | + .animate({ | ||
37 | + 'margin-left': offersetleft + 'px' | ||
38 | + }, 'slow', callback); | ||
39 | + | ||
40 | + } | ||
10 | $.fn.slider2.defaults = { | 41 | $.fn.slider2.defaults = { |
11 | index: 0, | 42 | index: 0, |
12 | shownum: 3, | 43 | shownum: 3, |
@@ -79,37 +110,6 @@ var $ = require('jquery'); | @@ -79,37 +110,6 @@ var $ = require('jquery'); | ||
79 | } | 110 | } |
80 | }); | 111 | }); |
81 | 112 | ||
82 | - function autoplay(index, limit, toright) { | ||
83 | - if (toright === true) { | ||
84 | - $('.next').trigger('click'); | ||
85 | - if (index === (limit - 3)) { | ||
86 | - autoplayrecycle(--index, limit, false); | ||
87 | - } else { | ||
88 | - autoplayrecycle(++index, limit, true); | ||
89 | - } | ||
90 | - } else { | ||
91 | - $('.prev').trigger('click'); | ||
92 | - if (index === 0) { | ||
93 | - autoplayrecycle(++index, limit, true); | ||
94 | - } else { | ||
95 | - autoplayrecycle(--index, limit, false); | ||
96 | - } | ||
97 | - } | ||
98 | - } | ||
99 | - | ||
100 | - function autoplayrecycle(index, limit, toright) { | ||
101 | - window.setTimeout(autoplay, $.fn.slider2.defaults.delaytime, index, limit, toright); | ||
102 | - } | ||
103 | - | ||
104 | - function changePic(index, width, callback) { | ||
105 | - var offersetleft = -(index * width); | ||
106 | - | ||
107 | - $('.img-list') | ||
108 | - .animate({ | ||
109 | - 'margin-left': offersetleft + 'px' | ||
110 | - }, 'slow', callback); | ||
111 | - | ||
112 | - } | ||
113 | }; | 113 | }; |
114 | 114 | ||
115 | }($)); | 115 | }($)); |
-
Please register or login to post a comment