fixed most of the problems with image proportions...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-04-25 23:41:59 +03:00
parent 543afbddfb
commit 8ad1b95399
2 changed files with 50 additions and 21 deletions

View File

@ -137,16 +137,44 @@ function updateImageProportions(){
if(Di == H){ if(Di == H){
images images
.each(function(_, img){ .each(function(_, img){
img.style.width = n + 'px' var o = img.getAttribute('orientation')
img.style.height = '' o = o == null ? 0 : o
// rotated images...
if(o == 90 || o == 270){
img.style.width = ''
img.style.height = n + 'px'
img.style.margin = -(n - di)/2 +'px '+ (n - di)/2 +'px'
} else {
img.style.width = n + 'px'
img.style.height = ''
img.style.margin = ''
}
}) })
// vertical viewer... // vertical viewer...
} else { } else {
images images
.each(function(_, img){ .each(function(_, img){
img.style.width = '' var o = img.getAttribute('orientation')
img.style.height = n + 'px' o = o == null ? 0 : o
// rotated images...
if(o == 90 || o == 270){
img.style.width = n + 'px'
img.style.height = ''
img.style.margin = -(n - di)/2 +'px '+ (n - di)/2 +'px'
} else {
img.style.width = ''
img.style.height = n + 'px'
img.style.margin = ''
}
}) })
} }
@ -166,6 +194,8 @@ function updateImageProportions(){
.each(function(_, img){ .each(function(_, img){
img.style.width = '' img.style.width = ''
img.style.height = '' img.style.height = ''
img.style.margin = ''
}) })
that.ribbons that.ribbons
@ -226,10 +256,10 @@ module.SingleImageView = core.ImageGridFeatures.Feature({
if(this.toggleSingleImage('?') == 'on'){ if(this.toggleSingleImage('?') == 'on'){
updateImageProportions.call(this) updateImageProportions.call(this)
this.config['single-image-scale'] = this.screenwidth this.config['single-image-scale'] = this.scale
} else { } else {
this.config['ribbon-scale'] = this.screenwidth this.config['ribbon-scale'] = this.scale
} }
}], }],
// update new images... // update new images...
@ -243,7 +273,6 @@ module.SingleImageView = core.ImageGridFeatures.Feature({
// need to see if the state has changed and doing this with // need to see if the state has changed and doing this with
// two separate pre/post callbacks (toggler callbacks) is // two separate pre/post callbacks (toggler callbacks) is
// harder than with two nested callbacks (action callbacks) // harder than with two nested callbacks (action callbacks)
// XXX this uses .screenwidth for scale, is this the right way to go?
['toggleSingleImage.pre', ['toggleSingleImage.pre',
function(){ function(){
var pre_state = this.toggleSingleImage('?') var pre_state = this.toggleSingleImage('?')
@ -257,9 +286,9 @@ module.SingleImageView = core.ImageGridFeatures.Feature({
// update scale... // update scale...
if(state != pre_state){ if(state != pre_state){
var w = this.screenwidth var s = this.scale
this.config['ribbon-scale'] = w this.config['ribbon-scale'] = s
this.screenwidth = this.config['single-image-scale'] || w this.scale = this.config['single-image-scale'] || s
} }
// ribbon mode -- restore original image size... // ribbon mode -- restore original image size...
@ -268,17 +297,16 @@ module.SingleImageView = core.ImageGridFeatures.Feature({
.each(function(_, img){ .each(function(_, img){
img.style.width = '' img.style.width = ''
img.style.height = '' img.style.height = ''
img.style.margin = ''
}) })
// XXX this still does not align correctly with
// rotated current image...
this.ribbons.centerImage() this.ribbons.centerImage()
// update scale... // update scale...
if(state != pre_state){ if(state != pre_state){
var w = this.screenwidth var s = this.scale
this.config['single-image-scale'] = w this.config['single-image-scale'] = s
this.screenwidth = this.config['ribbon-scale'] || w this.scale = this.config['ribbon-scale'] || s
} }
} }
} }
@ -307,11 +335,13 @@ module.SingleImageViewLocalStorage = core.ImageGridFeatures.Feature({
return return
} }
console.log('!!!!!!!!!!!!!!', this.config['ribbon-scale'])
if(this.toggleSingleImage('?') == 'on'){ if(this.toggleSingleImage('?') == 'on'){
this.screenwidth = this.config['single-image-scale'] || this.screenwidth this.scale = this.config['single-image-scale'] || this.scale
} else { } else {
this.screenwidth = this.config['ribbon-scale'] || this.screenwidth this.scale = this.config['ribbon-scale'] || this.scale
} }
}], }],
], ],

View File

@ -2193,10 +2193,7 @@ var RibbonsPrototype = {
height: w, height: w,
}) })
image.css({ image.css({
'margin-top': -((w - h)/2), 'margin': -((w - h)/2) +'px '+ (w - h)/2 + 'px'
'margin-bottom': -((w - h)/2),
'margin-left': (w - h)/2,
'margin-right': (w - h)/2,
}) })
} else if((o == 0 || o == 180) && image_p != viewer_p){ } else if((o == 0 || o == 180) && image_p != viewer_p){
@ -2216,6 +2213,8 @@ var RibbonsPrototype = {
}) })
} }
}) })
return this
}, },
// center a ribbon vertically... // center a ribbon vertically...