|
33 | 33 | .jkscroll-bar-top,.jkscroll-bar-bot{position:absolute;height:15px;left:0px;width:100%;cursor:pointer;background:url(images/bar-gray.gif) no-repeat 0 0 #bbdef6;}
|
34 | 34 | .jkscroll-bar-top{top:0px;display:none;}
|
35 | 35 | .jkscroll-bar-bot{bottom:0px;background-position:0 -15px;display:none;}
|
36 |
| - .jkscroll-bar-mid{position:absolute;top:15px;width:15px;height:100px;border:1px solid #A3C3D5;background:url(images/bar-gray.gif) repeat-y -45px 0 #e0f1fc;} |
| 36 | + .jkscroll-bar-mid{position:absolute;top:0px;width:15px;height:100px;border:1px solid #A3C3D5;background:url(images/bar-gray.gif) repeat-y -45px 0 #e0f1fc;} |
37 | 37 | .jkscroll-wrap .hover{background:url(images/bar-gray.gif) repeat-y -58px 0 #dceffc;}
|
38 | 38 | /* simple */
|
39 | 39 | .jkscroll-wrap .jkscroll-simple{width:12px;background:#f2f2f2;border-left:1px solid #dadada;}
|
@@ -205,21 +205,42 @@ <h3>译文:</h3>
|
205 | 205 | } else {
|
206 | 206 | that.now += 15;
|
207 | 207 | }
|
208 |
| - console.log('now', that.now); |
209 | 208 | that.scroll();
|
210 | 209 | });
|
211 | 210 | },
|
212 | 211 | scroll : function(){
|
213 | 212 | var n = this.now;
|
214 |
| - if(n < this.up.offsetHeight){ |
215 |
| - n = this.up.offsetHeight; |
| 213 | + if(n < 0){ |
| 214 | + n = 0; |
216 | 215 | }
|
217 |
| - if(n > this.main.offsetHeight - this.up.offsetHeight - this.dragger.offsetHeight){ |
218 |
| - n = this.main.offsetHeight - this.up.offsetHeight - this.dragger.offsetHeight; |
| 216 | + if(n > this.main.offsetHeight - this.dragger.offsetHeight){ |
| 217 | + n = this.main.offsetHeight - this.dragger.offsetHeight; |
219 | 218 | }
|
| 219 | + console.log(n); |
| 220 | + n = (n * this.content.offsetHeight) / this.main.offsetHeight; |
220 | 221 | this.now = n;
|
221 | 222 | this.content.style.top = -(n - 15) + 'px';
|
222 | 223 | this.dragger.style.top = n + 'px';
|
| 224 | + }, |
| 225 | + dragBar : function(handler){ |
| 226 | + var startY = 0, |
| 227 | + lastY = 0, |
| 228 | + doc = document, |
| 229 | + drag = { |
| 230 | + down : function(e){ |
| 231 | + startY = e.clientY - handler.offsetTop; |
| 232 | + dog.on(doc, 'mouseup', drag.up); |
| 233 | + }, |
| 234 | + move : function(){ |
| 235 | + lastY = e.clientY - startY; |
| 236 | + handler.style.top = lastY + 'px'; |
| 237 | + }, |
| 238 | + up : function(){ |
| 239 | + dog.off(doc, 'mousemove', drag.move); |
| 240 | + dog.off(doc, 'mouseup', drag.up); |
| 241 | + } |
| 242 | + } |
| 243 | + dog.on(handler, 'mousedown', drag.down); |
223 | 244 | }
|
224 | 245 | }
|
225 | 246 | var defaults = {
|
|
0 commit comments