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 <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-11-16 16:49:12 +03:00
parent 6c1c9b6e58
commit f1c9bdce93
2 changed files with 27 additions and 2 deletions

View File

@ -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)

View File

@ -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){