r2637 - photoviewer: fix for resizing

r2637 - photoviewer: fix for resizing


Author: joern.zaefferer
Date: Tue Jun 2 01:43:48 2009
New Revision: 2637
Modified:
branches/labs/photoviewer/ui/ui.photoviewer.js
Log:
photoviewer: fix for resizing
Modified: branches/labs/photoviewer/ui/ui.photoviewer.js
==============================================================================
--- branches/labs/photoviewer/ui/ui.photoviewer.js    (original)
+++ branches/labs/photoviewer/ui/ui.photoviewer.js    Tue Jun 2 01:43:48 2009
@@ -50,8 +50,9 @@
            $(window).resize(function() {
                if (!self.currentAnchor)
                    return;
-                self._resize(self._viewer());
+                self._resize(self._viewer().find("img"));
                self._position(self._viewer());
+                self._shadow(self._viewer());
            });
            if ($.fn.mousewheel) {
                $(document).mousewheel(function(event, delta) {
@@ -138,7 +139,7 @@
            this._viewer("new").attr("title", anchor.title +
this.options.titleSuffix).children("img").attr("src",
anchor.href).one("load", function() {
                var $this = $(this).parent();
                self._hideLoadingIndicator();
-                self._resize($this);
+                self._resize($(this));
                self._position($this);
                self._shadow($this);
                self._overlay().attr("title", anchor.title + self.options.titleSuffix)
@@ -175,12 +176,16 @@
        },
        
        _resize: function(img) {
+            var border = 30;
            img.css("width", "").css("height", "");
-            var outerWidth = img.outerWidth(),
-                outerHeight = img.outerHeight(),
-                borderWidth = outerWidth - img.width(),
-                borderHeight = outerHeight - img.height(),
+            var imgx = img.parent();
+            var outerWidth = imgx.width(),
+                outerHeight = imgx.height(),
+                borderWidth = 30,
+                borderHeight = 30,
                ratio = Math.min(Math.min($(window).width() - 36, outerWidth) /
outerWidth, Math.min($(window).height() - 60, outerHeight) / outerHeight);
+            //console.log(imgx.outerWidth(), imgx.outerHeight(), imgx.width(),
imgx.height())
+            //console.log(img, outerWidth, outerHeight, borderWidth, borderHeight,
ratio)
            if (ratio < 1) {
                img.css({
                    width: Math.round(ratio * outerWidth - borderWidth),
@@ -223,6 +228,8 @@
        _shadow: function(viewer) {
            if (!$.support.canvas)
                return;
+            
+            viewer.children("canvas").remove();
            
            var width = viewer.width() + 15,
                height = viewer.height() + 15,