some minor refactoring + bugfix: now .fitRibbon(..) also triggers partial image loading...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-11-06 14:25:09 +03:00
parent b88be66316
commit 73b407fcfa
2 changed files with 29 additions and 3 deletions

View File

@ -219,6 +219,15 @@ module.RibbonsPrototype = {
return W/w
},
// XXX this does not account for ribbon spacing...
getScreenHeightRibbons: function(scale){
var scale = scale == null ? 1 : scale/this.getScale()
var H = this.viewer.height()
var h = this.getVisibleImageSize('height') * scale
return H/h
},
// Get ribbon set scale...
//
@ -1606,8 +1615,7 @@ module.RibbonsPrototype = {
n = n || 1
fit_whole_images = fit_whole_images == null ? true : false
var h = this.getVisibleImageSize('height', 1)
var scale = this.viewer.height() / (h * n)
var scale = this.getScreenHeightRibbons(1) / n
var w = this.getVisibleImageSize('width', 1)
var W = this.viewer.width()

View File

@ -607,9 +607,12 @@ actions.Actions(Client, {
: data.getImage(target)
// align current ribbon...
// NOTE: the ordering of calls here makes it simpler to load
// data into ribbons based on target gid... i.e. first
// we know the section we need then align it vertically...
this
.centerRibbon(gid)
.centerImage(gid)
.centerRibbon(gid)
// align other ribbons...
var ribbon = data.getRibbon(gid)
@ -1012,6 +1015,21 @@ module.PartialRibbons = Feature({
.on('fitImage.pre', this.tag, function(n){
this.updateRibbonSize('current', n || 1)
})
.on('fitRibbon.pre', this.tag, function(n){
n = n || 1
// convert target height in ribbons to width in images...
// NOTE: this does not account for compensation that
// .updateRibbonSize(..) makes for fitting whole image
// counts, this is a small enough error so as not
// to waste time on...
var s = this.ribbons.getScale()
var h = this.ribbons.getScreenHeightRibbons()
var w = this.ribbons.getScreenWidthImages()
var nw = w / (h/n)
this.updateRibbonSize('current', nw)
})
},
remove: function(actions){
actions.mixout(PartialRibbonsActions)