failed to make .updateImageProportions() use vmin instead of px + some refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-12-02 23:52:56 +03:00
parent d886704fce
commit 56a8832876
2 changed files with 27 additions and 10 deletions

View File

@ -135,12 +135,6 @@ var SingleImageActions = actions.Actions({
return
}
/* XXX these do not account for margins....
var img = this.ribbons.getImage()[0] || images[0]
var s = getComputedStyle(img)
var w = parseFloat(s.width)
var h = parseFloat(s.height)
//*/
var w = this.ribbons.getVisibleImageSize('width', 1)
var h = this.ribbons.getVisibleImageSize('height', 1)
@ -173,6 +167,9 @@ var SingleImageActions = actions.Actions({
* (threshold/c - 1)
// new size...
var n = di + d
/*/ XXX for some reason 'vmin' ignores scale...
var n = ((di + d) / di) * 100
//*/
// XXX not sure why we need to get animation frame here...
getAnimationFrame(function(){
@ -199,9 +196,16 @@ var SingleImageActions = actions.Actions({
img.style[a] = ''
img.style[b] = n + 'px'
img.style.margin = -(n - di)/2 +'px '+ (n - di)/2 +'px'
/*/ XXX for some reason 'vmin' ignores scale...
img.style[b] = n + 'vmin'
img.style.margin = -(n - 100)/2 +'vmin '+ (n - 100)/2 +'vmin'
//*/
} else {
img.style[a] = n + 'px'
/*/ XXX for some reason 'vmin' ignores scale...
img.style[a] = n + 'vmin'
//*/
img.style[b] = ''
img.style.margin = ''
}
@ -334,7 +338,7 @@ module.SingleImageView = core.ImageGridFeatures.Feature({
handlers:[
// update config...
//['resizing.post',
['resizingDone',
['resizingDone resizingWindow',
function(){
// prevent this from doing anything while no viewer...
if(!this.ribbons

View File

@ -553,15 +553,28 @@ module.ViewerActions = actions.Actions({
// align current ribbon...
this.ribbons.centerRibbon(target)
}],
centerViewer: ['- Interface/Center the viewer',
function(target){
/*
this
.centerImage(target)
.centerRibbon(target)
*/
}],
// This is called by the window resize event handler...
//
// NOTE: since the centering is passive (done in CSS) we do not need
// to do anything here, but this is needed for legacy or
// compatibility code that needs to update stuff when resizing
// viewer...
// To see the list of handlers call:
// .getHandlerDocStr('resizingWindow')
resizingWindow: ['- Interface/',
core.notUserCallable(function(){
// This is the window resize event...
})],
focusImage: [
function(target, list){
var ribbons = this.ribbons
@ -1000,7 +1013,7 @@ module.Viewer = core.ImageGridFeatures.Feature({
// this will prevent centering calls from overlapping...
that.__centering_on_resize = true
that.centerViewer()
that.resizingWindow()
delete that.__centering_on_resize
}