diff --git a/ui/ribbons.js b/ui/ribbons.js index 2d94506b..bb49c884 100755 --- a/ui/ribbons.js +++ b/ui/ribbons.js @@ -703,17 +703,38 @@ function centerRibbon(ribbon, image, mode){ // a shorthand... -function centerRibbons(mode, no_skip_current){ +function centerRibbons(mode, no_skip_current, no_skip_hidden){ + var R = $('.viewer').height()/2 + var cur = getImage() + var h = cur.height() + return $('.ribbon') .each(function(){ + var ribbon = $(this) + // // skip empty ribbons... // if($(this).find('.image').length == 0){ // return // } - if(no_skip_current == true && $(this).find('.current.image').length > 0){ + + // skip ribbon containing current image... + if(no_skip_current == true && ribbon.find('.current.image').length > 0){ return } - centerRibbon($(this), null, mode) + + // skip ribbons outside of the viewer... + // NOTE: we are accounting for position relative to image... + // NOTE: we need to factor in image height as the distance is + // between cleanly ribbon centers will mean that half + // hidden ribbons will not get updated... + if(no_skip_hidden != true){ + var d = Math.abs(getRelativeVisualPosition(cur, ribbon).top) + if( d - h/2 >= R ){ + return + } + } + + centerRibbon(ribbon, null, mode) }) } diff --git a/ui/setup.js b/ui/setup.js index 12620c99..7a2db01d 100755 --- a/ui/setup.js +++ b/ui/setup.js @@ -95,16 +95,17 @@ function setupDataBindings(viewer){ return } + /* NOTE: this is not really needed as we are skipping this stuff + // in centerRibbons(...) // skip the whole thing if the ribbon is not visible, i.e. outside // of viewer area... - // NOTE: we are accounting for position relative to image... - // NOTE: we do not need to account for image height because - // of origin and vertical-align... (check) var R = $('.viewer').height()/2 + var h = image.height() var d = Math.abs(getRelativeVisualPosition(image, ribbon).top) - if( d >= R ){ + if( d - h/2 >= R ){ return } + */ /* NOTE: this is commented out as it is not really needed now * uncomment if a need arises...