From: Michael Stapelberg Date: Sat, 23 Jul 2011 12:09:02 +0000 (+0200) Subject: gallery: add proper previous / next buttons, progress indicator X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9e4837278ba88ca483e67c0a6edc813a77996a67;p=i3%2Fi3.github.io gallery: add proper previous / next buttons, progress indicator --- diff --git a/css/style.css b/css/style.css index 564611f..b568027 100644 --- a/css/style.css +++ b/css/style.css @@ -270,9 +270,10 @@ img { position: fixed; left: 50%; top: 50%; - width: 64px; - height: 64px; - background-color: red; + width: 58px; + height: 60px; + background-color: black; + background-image: url('/img/loading.gif'); opacity: 0.9; z-index: 20; display: none; @@ -305,17 +306,19 @@ img { width: 64px; height: 64px; border-radius: 4px; - background-color: green; - z-index: 19; + background-color: black; + z-index: 22; + opacity: 0.7; } #imgleft { left: 0; + background-image: url('/img/prevbtn.png'); } #imgright { right: 0; - background-color: blue; + background-image: url('/img/nextbtn.png'); } /* clearfix */ diff --git a/img/loading.gif b/img/loading.gif new file mode 100644 index 0000000..f51f9c6 Binary files /dev/null and b/img/loading.gif differ diff --git a/img/nextbtn.png b/img/nextbtn.png new file mode 100644 index 0000000..f5d1190 Binary files /dev/null and b/img/nextbtn.png differ diff --git a/img/prevbtn.png b/img/prevbtn.png new file mode 100644 index 0000000..79506e9 Binary files /dev/null and b/img/prevbtn.png differ diff --git a/js/gallery.js b/js/gallery.js index 284fb21..e601b2e 100644 --- a/js/gallery.js +++ b/js/gallery.js @@ -5,6 +5,14 @@ function initGallery() { $(document).ready(function() { $('.shot span').css('color', '#888'); + $('#imgleft, #imgright').mouseover(function() { + $(this).css('opacity', 0.9); + }); + + $('#imgleft, #imgright').mouseout(function() { + $(this).css('opacity', 0.7); + }); + $('.shot img').mouseover(function() { $(this).parent().parent().children('span').css('color', 'white'); }); @@ -28,8 +36,6 @@ function initGallery() { }); var wheelhandler = function(event, delta) { - //console.log('event = ' + event + ', delta = ' + delta); - // if we are not in the slideshow mode, process the event as normal if (!$('#mask').is(':visible')) { return true; @@ -74,7 +80,7 @@ function initGallery() { $('#loading').hide(); var element = $(''); element.attr({ 'src': url, 'width':dims.width }); - element.css({ 'position': 'absolute', 'top':dims.top + 'px', 'left':dims.left + 'px' }); + element.css({ 'z-index': 21, 'position': 'absolute', 'top':dims.top + 'px', 'left':dims.left + 'px' }); if (direction !== undefined) { // slide from right to left if (direction === 'left') { @@ -100,10 +106,8 @@ function initGallery() { }; if (img.complete) { - //console.log('image already in cache'); loadcomplete(); } else { - //console.log('loading image'); img.onload = loadcomplete; } }; @@ -136,8 +140,7 @@ function initGallery() { showmask(); var full = $(this).parent().attr('href'); - var loading = $('#loading'); - loading.show(); + $('#loading').show(); loadimage(full, undefined, false); @@ -152,13 +155,13 @@ function initGallery() { var next = images[idx+1]; if (next === undefined) { - //console.log('there is no next image'); return false; } - //console.log('loading next one: ' + next); + $('#imgright').css('opacity', 1.0).animate({ opacity: 0.7 }, 500); // slide out the current image var winW = $(window).width(); + $('#loading').show(); $('#maskinner img').animate({ 'left': '-=' + (winW - 64) }, 'fast', function() { $(this).remove(); }); @@ -176,11 +179,10 @@ function initGallery() { var prev = images[idx-1]; if (prev === undefined) { - //console.log('there is no next image'); return false; } - //console.log('loading prev one: ' + prev); + $('#imgleft').css('opacity', 1.0).animate({ opacity: 0.7 }, 500); // slide out the current image var winW = $(window).width(); $('#maskinner img').animate({ 'left': '+=' + winW }, 'fast', function() { diff --git a/js/gallery.min.js b/js/gallery.min.js index 623d4ff..a2bafac 100644 --- a/js/gallery.min.js +++ b/js/gallery.min.js @@ -1,4 +1,4 @@ function initGallery(){ (function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);function a(j){j=j||location.href;return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)};$.fn[c].delay=50;g[c]=$.extend(g[c],{setup:function(){if(d){return false}$(f.start)},teardown:function(){if(d){return false}$(f.stop)}});f=(function(){var j={},p,m=a(),k=function(q){return q},l=k,o=k;j.start=function(){p||n()};j.stop=function(){p&&clearTimeout(p);p=b};function n(){var r=a(),q=o(m);if(r!==m){l(m=r,q);$(e).trigger(c)}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q}}p=setTimeout(n,$.fn[c].delay)}$.browser.msie&&!d&&(function(){var q,r;j.start=function(){if(!q){r=$.fn[c].src;r=r&&r+a();q=$('