txt.js: improved scrolling
This commit is contained in:
parent
1259c8974b
commit
f5dfeb2ce0
1 changed files with 5 additions and 7 deletions
|
@ -36,24 +36,22 @@ txtjs.open = function(url) {
|
|||
.on({
|
||||
mousedown: function(e) {
|
||||
var offset = 'offsetY' in e ? e.offsetY : e.layerY;
|
||||
document.body.scrollTop = offset / factor;
|
||||
//Ox.print('!', offset)
|
||||
document.body.scrollTop = offset / factor + margin - 16;
|
||||
}
|
||||
})
|
||||
.appendTo($scroll),
|
||||
textHeight, scrollTextHeight, factor;
|
||||
factor, margin;
|
||||
text = Ox.encodeHTMLEntities(text)
|
||||
.replace(/\r\n/g, '\n')
|
||||
.replace(/[\r\n]/g, '<br>');
|
||||
$text.html(text);
|
||||
$scrollText.html(text);
|
||||
window.onresize = function() {
|
||||
textHeight = $text[0].clientHeight - window.innerHeight,
|
||||
scrollTextHeight = $scrollText[0].clientHeight - (window.innerHeight - 32),
|
||||
factor = scrollTextHeight / textHeight;
|
||||
margin = $text.width() * 0.1;
|
||||
factor = $scrollText[0].clientHeight / $text[0].clientHeight;
|
||||
};
|
||||
window.onscroll = function() {
|
||||
$scroll[0].scrollTop = window.pageYOffset * factor;
|
||||
$scroll[0].scrollTop = (window.pageYOffset - margin + 16) * factor;
|
||||
};
|
||||
window.onresize();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue