made next/prev ribbon actions behave in a stable manner...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-05-20 17:42:18 +04:00
parent c7a820d9c7
commit 9f291331b0
3 changed files with 13 additions and 10 deletions

View File

@ -10,6 +10,9 @@
| |
[_] BUG: jumping screen images does not load the adjacent ribbons... [_] BUG: jumping screen images does not load the adjacent ribbons...
| positioning is OK but ribbons are not fully visible... | positioning is OK but ribbons are not fully visible...
[_] make focus up/down chose a closest independently of direction...
| navigation should be stable and moving up then down should yield
| exactly the same result...
[_] 6% mark-based operations [_] 6% mark-based operations
[_] 33% cropping selection [_] 33% cropping selection
[X] marked [X] marked

View File

@ -743,39 +743,39 @@ function lastImage(mode){
// NOTE: if moving is 'next' these will chose the image after the current's order. // NOTE: if moving is 'next' these will chose the image after the current's order.
// NOTE: if an image with the same order is found, moving argument has no effect. // NOTE: if an image with the same order is found, moving argument has no effect.
// XXX make these select the closest image instead of the one based on
// direction...
// XXX these sometimes behave wrong at the start of the ribbon depending // XXX these sometimes behave wrong at the start of the ribbon depending
// on direction... // on direction...
function prevRibbon(moving, mode){ function prevRibbon(mode){
mode = mode == null ? NAV_DEFAULT : mode mode = mode == null ? NAV_DEFAULT : mode
var cur = $('.current.image') var cur = $('.current.image')
var target = getImageBefore(cur, var target = getImageBefore(cur,
getRibbon(cur).prevAll('.ribbon' + NAV_RIBBON_DEFAULT).first()) getRibbon(cur).prevAll('.ribbon' + NAV_RIBBON_DEFAULT).first())
// first image...
if(target.length == 0){ if(target.length == 0){
// XXX too complex??? // XXX too complex???
target = getRibbon(cur) target = getRibbon(cur)
.prevAll('.ribbon' + NAV_RIBBON_DEFAULT).first() .prevAll('.ribbon' + NAV_RIBBON_DEFAULT).first()
.find('.image' + mode).first() .find('.image' + mode).first()
} else if(moving == 'next' && cur.attr('order') != target.attr('order')){
} else {
var next = target.nextAll('.image' + mode).first() var next = target.nextAll('.image' + mode).first()
target = next.length > 0 ? next : target target = next.length > 0 ? next : target
} }
return centerView(focusImage(target)) return centerView(focusImage(target))
} }
function nextRibbon(moving, mode){ function nextRibbon(mode){
mode = mode == null ? NAV_DEFAULT : mode mode = mode == null ? NAV_DEFAULT : mode
var cur = $('.current.image') var cur = $('.current.image')
var target = getImageBefore(cur, var target = getImageBefore(cur,
getRibbon(cur).nextAll('.ribbon' + NAV_RIBBON_DEFAULT).first()) getRibbon(cur).nextAll('.ribbon' + NAV_RIBBON_DEFAULT).first())
// first image...
if(target.length == 0){ if(target.length == 0){
// XXX too complex??? // XXX too complex???
target = getRibbon(cur) target = getRibbon(cur)
.nextAll('.ribbon' + NAV_RIBBON_DEFAULT).first() .nextAll('.ribbon' + NAV_RIBBON_DEFAULT).first()
.find('.image' + mode).first() .find('.image' + mode).first()
} else if(moving == 'next' && cur.attr('order') != target.attr('order')){
var next = target.nextAll('.image' + mode).first()
target = next.length > 0 ? next : target
} }
return centerView(focusImage(target)) return centerView(focusImage(target))
} }

View File

@ -88,7 +88,7 @@ var KEYBOARD_CONFIG = {
Up: { Up: {
default: function(){ default: function(){
event.preventDefault() event.preventDefault()
prevRibbon(DIRECTION) prevRibbon()
centerRibbons() centerRibbons()
}, },
shift: function(){ shift: function(){
@ -105,7 +105,7 @@ var KEYBOARD_CONFIG = {
Down: { Down: {
default: function(){ default: function(){
event.preventDefault() event.preventDefault()
nextRibbon(DIRECTION) nextRibbon()
centerRibbons() centerRibbons()
}, },
shift: function(){ shift: function(){