diff --git a/ui (gen4)/ribbons.js b/ui (gen4)/ribbons.js index c75ce1fb..d4be82d5 100755 --- a/ui (gen4)/ribbons.js +++ b/ui (gen4)/ribbons.js @@ -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() diff --git a/ui (gen4)/viewer.js b/ui (gen4)/viewer.js index a3249093..b561f0b8 100755 --- a/ui (gen4)/viewer.js +++ b/ui (gen4)/viewer.js @@ -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)