Fixed scrolling.
This commit is contained in:
parent
896f3c643d
commit
2d07f95c55
2 changed files with 13 additions and 6 deletions
|
@ -148,11 +148,15 @@ List.prototype.attach = function(scene) {
|
||||||
});
|
});
|
||||||
$('body').mousemove(function(e){
|
$('body').mousemove(function(e){
|
||||||
if (sb.data('scrolling')) {
|
if (sb.data('scrolling')) {
|
||||||
var offset = e.pageY-sb.data('startY');
|
var offset = parseInt(sb.css('top'))+e.pageY-sb.data('startY');
|
||||||
if (offset > -1 && offset < c.height()-sb.height()) {
|
if (offset < 0) {
|
||||||
sb.css('top',offset);
|
offset = 0;
|
||||||
c.scrollTop(offset);
|
|
||||||
}
|
}
|
||||||
|
if (offset > c.height()-sb.height()) {
|
||||||
|
offset = c.height()-sb.height();
|
||||||
|
}
|
||||||
|
sb.css('top',offset);
|
||||||
|
c.scrollTop(c.height()/sb.height()*offset);
|
||||||
}
|
}
|
||||||
}).mouseup(function(){
|
}).mouseup(function(){
|
||||||
if ($.hasData(sb[0],'scrolling')) sb.removeData(['scrolling','startY']);
|
if ($.hasData(sb[0],'scrolling')) sb.removeData(['scrolling','startY']);
|
||||||
|
@ -178,6 +182,8 @@ List.prototype.update = function(){
|
||||||
$('<div style="clear:both">').appendTo(c).append('<div class="list-index">'+(i+1),'<div class="list-item">'+val);
|
$('<div style="clear:both">').appendTo(c).append('<div class="list-index">'+(i+1),'<div class="list-item">'+val);
|
||||||
});
|
});
|
||||||
c.height(this.height-26);
|
c.height(this.height-26);
|
||||||
|
c.find('.list-index').width(c.find('.list-index').last().width());
|
||||||
|
c.find('.list-item').width(c.width()-c.find('.list-index').width()-15)
|
||||||
var s = this.scrollbar.height(this.height-26);
|
var s = this.scrollbar.height(this.height-26);
|
||||||
s.children('.list-scrollbar').height(s.height()/c[0].scrollHeight*s.height()).css('display', s.children('.list-scrollbar').height()===c.height() ? 'none' : 'inline-block');
|
s.children('.list-scrollbar').height(s.height()/c[0].scrollHeight*s.height()).css('display', s.children('.list-scrollbar').height()===c.height() ? 'none' : 'inline-block');
|
||||||
this.el.find('.list-length').text('length: '+this.contents.length);
|
this.el.find('.list-length').text('length: '+this.contents.length);
|
||||||
|
|
|
@ -132,13 +132,14 @@
|
||||||
float: left;
|
float: left;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
margin-top: 0px;
|
margin-top: 0px;
|
||||||
font: bold 10px Verdana,sans-serif;
|
font: bold 10px monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
.list .list-item {
|
.list .list-item {
|
||||||
float: left;
|
float: left;
|
||||||
width: 70%;
|
width: 70%;
|
||||||
min-height: 18px;
|
height: 16px;
|
||||||
|
overflow: hidden;
|
||||||
margin-bottom: 0px;
|
margin-bottom: 0px;
|
||||||
margin-right: 2px;
|
margin-right: 2px;
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
|
|
Reference in a new issue