r2554 - photoviewer: handle window resize; ignore (most) mousewheel events while animated
Author: joern.zaefferer
Date: Wed May 13 07:13:32 2009
New Revision: 2554
Modified:
branches/photoviewer/ui/ui.photoviewer.js
Log:
photoviewer: handle window resize; ignore (most) mousewheel events while
animated
Modified: branches/photoviewer/ui/ui.photoviewer.js
==============================================================================
--- branches/photoviewer/ui/ui.photoviewer.js (original)
+++ branches/photoviewer/ui/ui.photoviewer.js Wed May 13 07:13:32 2009
@@ -46,17 +46,27 @@
break;
}
});
+ $(window).resize(function() {
+ if (!self.currentAnchor)
+ return;
+ if (self.options.resize) {
+ self._resize(self._viewer());
+ }
+ self._position(self._viewer());
+ });
if ($.fn.mousewheel) {
$(document).mousewheel(function(event, delta) {
if (!self.currentAnchor)
return;
+ event.preventDefault();
+ if (self.viewerElement.is(":animated"))
+ return;
if (delta < 0) {
self.next();
}
if (delta > 0) {
self.prev();
}
- return false;
});
}
},
@@ -110,14 +120,10 @@
}
this._viewer("new").attr("src", anchor.href).one("load", function() {
- $(this).css("width", "").css("height", "");
if (self.options.resize) {
self._resize($(this));
}
- $(this).css({
- left: $(window).width() / 2 - $(this).outerWidth() / 2 +
$(window).scrollLeft(),
- top: $(window).height() / 2 - $(this).outerHeight() / 2 +
$(window).scrollTop()
- });
+ self._position($(this));
if (visible) {
self.options.rotateIn.call(this, direction == "up" ? "down" : "up");
} else {
@@ -131,7 +137,15 @@
},
+ _position: function(img) {
+ img.css({
+ left: $(window).width() / 2 - img.outerWidth() / 2 +
$(window).scrollLeft(),
+ top: $(window).height() / 2 - img.outerHeight() / 2 +
$(window).scrollTop()
+ });
+ },
+
_resize: function(img) {
+ img.css("width", "").css("height", "");
var outerWidth = img.outerWidth(),
outerHeight = img.outerHeight(),
borderWidth = outerWidth - img.width(),