From f1c9bdce93d20277032697422f9221a08825aa97 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 16 Nov 2014 16:49:12 +0300 Subject: [PATCH] fixed a load problem -- ribbons.getVisibleImageSize(..) returned Infinity when no images loaded which resulted in loading EVERYTHING at once and then trimming... Signed-off-by: Alex A. Naanou --- ui (gen4)/Makefile | 4 +++- ui (gen4)/ribbons.js | 25 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/ui (gen4)/Makefile b/ui (gen4)/Makefile index dcc3bb7c..d217d2f8 100755 --- a/ui (gen4)/Makefile +++ b/ui (gen4)/Makefile @@ -140,8 +140,10 @@ dev: css chrome-app: $(APP_ZIP) $(CHROME_APP_BUILD_DIR) unzip -u $(APP_ZIP) -d $(CHROME_APP_BUILD_DIR) cp manifest.json $(CHROME_APP_BUILD_DIR) + cp -R images $(CHROME_APP_BUILD_DIR) rm -rf $(CHROME_APP_BUILD_DIR)/node_modules/ - #chrome --pack-extension=$(CHROME_APP_BUILD_DIR) --pack-extension-key=$(CHROME_APP_KEY) + # this needs to be OS independent... + chrome --pack-extension=$(CHROME_APP_BUILD_DIR) --pack-extension-key=$(CHROME_APP_KEY) # node-webkit win32 win32: $(APP_ZIP) $(WIN_BUILD_DIR) diff --git a/ui (gen4)/ribbons.js b/ui (gen4)/ribbons.js index 686a7649..fdd33092 100755 --- a/ui (gen4)/ribbons.js +++ b/ui (gen4)/ribbons.js @@ -212,18 +212,41 @@ module.RibbonsPrototype = { // gets the visible size of the image tile in pixels. // // XXX try and make image size the product of vmin and scale... + // XXX this might break when no images are loaded and proportions + // are not square... getVisibleImageSize: function(dim, scale){ scale = scale || this.getScale() dim = dim == null ? 'width' : dim var img = this.viewer.find(IMAGE) + var tmp - return dim == 'height' ? img.outerHeight(true) * scale + // if no images are loaded create one temporarily.... + if(img.length == 0){ + img = tmp = this.createImage('__tmp_image__') + .css({ + position: 'absolute', + visibility: 'hidden', + top: '-200%', + left: '-200%', + }) + .appendTo(this.viewer) + } + + // do the calc... + var res = dim == 'height' ? img.outerHeight(true) * scale : dim == 'width' ? img.outerWidth(true) * scale : dim == 'max' ? Math.max(img.outerHeight(true), img.outerWidth(true)) * scale : dim == 'min' ? Math.min(img.outerHeight(true), img.outerWidth(true)) * scale : null + + // remove the tmp image we created... + if(tmp != null){ + tmp.remove() + } + + return res }, getScreenWidthImages: function(scale, min){