Skip to content

Commit 7535e64

Browse files
author
zhangyonghong
committed
update
1 parent 34a4917 commit 7535e64

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

c/3/index.html

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
.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;}
3434
.jkscroll-bar-top{top:0px;display:none;}
3535
.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;}
3737
.jkscroll-wrap .hover{background:url(images/bar-gray.gif) repeat-y -58px 0 #dceffc;}
3838
/* simple */
3939
.jkscroll-wrap .jkscroll-simple{width:12px;background:#f2f2f2;border-left:1px solid #dadada;}
@@ -205,21 +205,42 @@ <h3>译文:</h3>
205205
} else {
206206
that.now += 15;
207207
}
208-
console.log('now', that.now);
209208
that.scroll();
210209
});
211210
},
212211
scroll : function(){
213212
var n = this.now;
214-
if(n < this.up.offsetHeight){
215-
n = this.up.offsetHeight;
213+
if(n < 0){
214+
n = 0;
216215
}
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;
219218
}
219+
console.log(n);
220+
n = (n * this.content.offsetHeight) / this.main.offsetHeight;
220221
this.now = n;
221222
this.content.style.top = -(n - 15) + 'px';
222223
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);
223244
}
224245
}
225246
var defaults = {

0 commit comments

Comments
 (0)