From de94712fbdfda61912f6f94209b54ad975977d71 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Sun, 6 Nov 2011 10:29:33 +0800 Subject: [PATCH] Add scrolling support for world list --- web/css/dynmap_style.css | 4 ++++ web/js/map.js | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/web/css/dynmap_style.css b/web/css/dynmap_style.css index eda03af2..fd6fcee6 100644 --- a/web/css/dynmap_style.css +++ b/web/css/dynmap_style.css @@ -533,6 +533,10 @@ overflow:hidden; } +.worldlist { + overflow:hidden; +} + /******************* * players on the map */ diff --git a/web/js/map.js b/web/js/map.js index 047065d9..8d24028e 100644 --- a/web/js/map.js +++ b/web/js/map.js @@ -176,12 +176,39 @@ DynMap.prototype = { } if(!nopanel) sidebar.appendTo(container); + + // World scrollbuttons + var upbtn_world = $('
') + .addClass('scrollup') + .bind('mousedown mouseup', function(event){ + if(event.type == 'mousedown'){ + worldlist.animate({"scrollTop": "-=300px"}, 3000, 'linear'); + }else{ + worldlist.stop(); + } + }); + var downbtn_world = $('
') + .addClass('scrolldown') + .bind('mousedown mouseup', function(event){ + if(event.type == 'mousedown'){ + worldlist.animate({"scrollTop": "+=300px"}, 3000, 'linear'); + }else{ + worldlist.stop(); + } + }); // Worlds var worldlist; $('
') .append($('').text('Map Types')) - .append(me.worldlist = worldlist = $('
    ').addClass('worldlist')) + .append(upbtn_world) + .append(me.worldlist = worldlist = $('
      ').addClass('worldlist') + .bind('mousewheel', function(event, delta){ + this.scrollTop -= (delta * 10); + event.preventDefault(); + }) + ) + .append(downbtn_world) .appendTo(panel); $.each(me.worlds, function(index, world) { @@ -250,6 +277,16 @@ DynMap.prototype = { .appendTo(panel); var updateHeight = function() { + if(sidebar.innerHeight() > (2*worldlist.scrollHeight())) { /* Big enough */ + worldlist.height(worldlist.scrollHeight()); + upbtn_world.toggle(false); + downbtn_world.toggle(false); + } + else{ + worldlist.height(sidebar.innerHeight() / 2); + upbtn_world.toggle(true); + downbtn_world.toggle(true); + } 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);