|
27 | 27 | auto:true |
28 | 28 | }; |
29 | 29 |
|
30 | | - var extend = function(target,source){ |
| 30 | + var assign = function(target,source){ |
31 | 31 | var res = {}; |
32 | 32 | if(Object.assign){ |
33 | 33 | return Object.assign(res,target,source); |
|
46 | 46 | } |
47 | 47 |
|
48 | 48 | function Slider( selector, options ) { |
49 | | - var config = extend(defaultOption,options); |
| 49 | + var config = assign(defaultOption,options); |
50 | 50 | return new Slider.init( selector, config ); |
51 | 51 | } |
52 | 52 |
|
|
88 | 88 | this.auto && this.autoRun(); |
89 | 89 | this.wrap.addEventListener('touchstart',this,false); |
90 | 90 | this.wrap.addEventListener('touchmove',this,false); |
91 | | - document.body.addEventListener('touchend',this,false); |
| 91 | + this.wrap.addEventListener('touchend',this,false); |
92 | 92 | this.wrap.addEventListener('mousedown',this,false); |
93 | 93 | this.wrap.addEventListener('mousemove',this,false); |
94 | | - document.body.addEventListener('mouseup',this,false); |
| 94 | + this.wrap.addEventListener('mouseup',this,false); |
95 | 95 | }, |
96 | 96 | handleEvent:function(e){ |
97 | 97 | var type = e.type; |
|
102 | 102 | switch(type){ |
103 | 103 | case 'mousedown': |
104 | 104 | case 'touchstart': |
105 | | - this.axis.x = e.clientX; |
| 105 | + this.axis.x = e.pageX; |
106 | 106 | this.axis.y = e.clientY; |
107 | 107 | this.enableSlide = true; |
108 | 108 | this.auto = false; |
109 | 109 | clearTimeout(this.timmerId); |
110 | 110 | break; |
111 | 111 | case 'mouseup': |
112 | 112 | case 'touchend': |
113 | | - var distance = e.clientX - this.axis.x; |
| 113 | + var distance = e.pageX - this.axis.x; |
114 | 114 | var bounce = Math.round(this.width * this.bounce); |
115 | 115 | this.enableSlide = false; |
116 | 116 | if(Math.abs(distance)>bounce){ |
|
172 | 172 | return { |
173 | 173 | WebkitTransform:"translate3d(" + distance + ",0px,0px)", |
174 | 174 | transform:"translate3d(" + distance + ",0px,0px)", |
175 | | - WebkitTransition : 'translate '+ this.speed+' ease', |
176 | | - transition:'translate '+ this.speed+' ease' |
| 175 | + WebkitTransition : 'none', |
| 176 | + transition:'none' |
177 | 177 | } |
178 | 178 | }, |
179 | 179 | animate:function(distance){ |
180 | 180 | return { |
181 | 181 | WebkitTransform:"translate3d(" + distance + ",0px,0px)", |
182 | 182 | transform:"translate3d(" + distance + ",0px,0px)", |
183 | 183 | WebkitTransition : 'all '+ this.speed+' ease', |
184 | | - transition:'all '+ this.speed+' ease' |
| 184 | + transition:'all '+ this.speed+' ease', |
| 185 | + visibility: 'visible', |
| 186 | + zIndex:9 |
185 | 187 | } |
186 | 188 | }, |
187 | 189 | noAnimate:function(distance){ |
188 | 190 | return { |
189 | 191 | WebkitTransform:"translate3d(" + distance + ",0px,0px)", |
190 | 192 | transform:"translate3d(" + distance + ",0px,0px)", |
191 | 193 | WebkitTransition : 'none', |
192 | | - transition:'none' |
| 194 | + transition:'none', |
| 195 | + visibility: 'hidden', |
| 196 | + zIndex:0 |
193 | 197 | } |
194 | 198 | }, |
195 | 199 | next:function(){ |
|
0 commit comments