Hides scrollbuttons when they are not needed.

This commit is contained in:
FrozenCow 2011-03-17 21:10:35 +01:00
parent 79c2989b37
commit c13517949b

View File

@ -20,6 +20,11 @@ function splitArgs(s) {
function swtch(value, options, defaultOption) { function swtch(value, options, defaultOption) {
return (options[value] || defaultOption)(value); return (options[value] || defaultOption)(value);
} }
(function( $ ){
$.fn.scrollHeight = function(height) {
return this[0].scrollHeight;
};
})($);
function DynMapType() { } function DynMapType() { }
DynMapType.prototype = { DynMapType.prototype = {
@ -217,10 +222,14 @@ DynMap.prototype = {
.append(downbtn) .append(downbtn)
.appendTo(panel); .appendTo(panel);
playerlist.height(sidebar.innerHeight() - (playerlist.offset().top - worldlist.offset().top) - 64); // here we need a fix to avoid the static value, but it works fine this way :P var updateHeight = function() {
$(window).resize(function() {
playerlist.height(sidebar.innerHeight() - (playerlist.offset().top - worldlist.offset().top) - 64); // here we need a fix to avoid the static value, but it works fine this way :P playerlist.height(sidebar.innerHeight() - (playerlist.offset().top - worldlist.offset().top) - 64); // here we need a fix to avoid the static value, but it works fine this way :P
}); var scrollable = playerlist.scrollHeight() > playerlist.height();
upbtn.toggle(scrollable);
downbtn.toggle(scrollable);
};
updateHeight();
$(window).resize(updateHeight);
// The Compass // The Compass
var compass = $('<div/>') var compass = $('<div/>')
@ -490,7 +499,7 @@ DynMap.prototype = {
me.messagelist.show(); me.messagelist.show();
//var scrollHeight = jQuery(me.messagelist).attr('scrollHeight'); //var scrollHeight = jQuery(me.messagelist).attr('scrollHeight');
var scrollHeight = me.messagelist[0].scrollHeight; var scrollHeight = me.messagelist.scrollHeight();
messagelist.scrollTop(scrollHeight); messagelist.scrollTop(scrollHeight);
} }
}, },