From fd96a2ccb6ada2f6618d1aca022d6bce62fe5ae0 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 3 Jun 2013 23:36:40 +0400 Subject: [PATCH] fixed a couple of bugs in manual sorting... Signed-off-by: Alex A. Naanou --- ui/TODO.otl | 91 +++++++++++++++++++++++++-------------------- ui/data.js | 23 ++++++------ ui/keybindings.js | 94 +++++++++++++++++++++++++++-------------------- 3 files changed, 118 insertions(+), 90 deletions(-) diff --git a/ui/TODO.otl b/ui/TODO.otl index aa1a20b4..e4061a1d 100755 --- a/ui/TODO.otl +++ b/ui/TODO.otl @@ -89,8 +89,8 @@ Roadmap -[_] 25% Gen 3 current todo - [_] 51% High priority +[_] 27% Gen 3 current todo + [_] 54% High priority [_] BUG: sometimes duplicate images get loaded... | this happens when jumping back and forth on the mid ribbon until | the last element shows up and then moving left until the frame @@ -99,46 +99,21 @@ Roadmap | | $('[order='+$('.current.image').attr('order')+']').length | - [_] BUG: aligning still sometimes gets off... - | ...after rotating a number of images - | - | XXX this is likely a side effect of loading duplicates... - | - | happens when: - | - getScreenWidthInImages() < 2 - | - looking through images in one direction and back, some get misaligned - | ...this is stable behaviour by centerRibbon(...), - | calling it again will not fix this. - | moving next/prev will fix the issue until it comes back again - | - affected by LOAD_SCREENS and number of images in ribbon - | current figures: - | Ribbon: 18 - | Position going forward: 4 - | Position going back: 1 - | LOAD_SCREENS: 6 - | NOTE: changing LOAD_SCREENS moves the affected positions. - | NOTE: had a similar bug where some images still kept their - | prior sizing after recycling... - | ...check if centerRibbon(...) and correctImageProportionsForRotation(...) - | are called in right sequence... - [X] BUG: changing window size (F11) in single image modes messes things up... - | some images are of different sizes (newly loaded) and aligned in a wrong way... - | - | appears not to affect square-fit view... - | - | until we cycle to ribbon mode and back... - | - | Q: does this trigger the on-resize event??? - | A: no, not connected... - | - | possible that this is connected with the align/load bug... - | - | appears to be a state leak, this affects: - | - correctImageProportionsForRotation(image) -- mis-alignes images - | while after cycling single image mode, behaves correctly... - | - affects finNImages(...) -- uses old size of viewer... [_] BUG: jumping screen images does not load the adjacent ribbons... | positioning is OK but ribbons are not fully visible... + [_] BUG: shifting ribbon left sometimes results in wrong order... + | i.e. an image with order 12 before image with order 11 + | + | Example: + | - default image set + | - move first image 2 positions right + | + | Resulting state: + | - current image order: 12 + | - next image order: 11 + | - prev image order: 10 + | + | This is stably reproducible. [_] ASAP: test on Android... [_] 0% Tablet UI [_] screen buttons @@ -214,6 +189,42 @@ Roadmap [_] caching config [_] BUG: BASE_URL seems to gain a new trailing '/' on each save... | low priority as this does not affect anything... + [X] BUG: changing window size (F11) in single image modes messes things up... + | some images are of different sizes (newly loaded) and aligned in a wrong way... + | + | appears not to affect square-fit view... + | + | until we cycle to ribbon mode and back... + | + | Q: does this trigger the on-resize event??? + | A: no, not connected... + | + | possible that this is connected with the align/load bug... + | + | appears to be a state leak, this affects: + | - correctImageProportionsForRotation(image) -- mis-alignes images + | while after cycling single image mode, behaves correctly... + | - affects finNImages(...) -- uses old size of viewer... + [X] BUG: aligning still sometimes gets off... + | ...after rotating a number of images + | + | happens when: + | - getScreenWidthInImages() < 2 + | - looking through images in one direction and back, some get misaligned + | ...this is stable behaviour by centerRibbon(...), + | calling it again will not fix this. + | moving next/prev will fix the issue until it comes back again + | - affected by LOAD_SCREENS and number of images in ribbon + | current figures: + | Ribbon: 18 + | Position going forward: 4 + | Position going back: 1 + | LOAD_SCREENS: 6 + | NOTE: changing LOAD_SCREENS moves the affected positions. + | NOTE: had a similar bug where some images still kept their + | prior sizing after recycling... + | ...check if centerRibbon(...) and correctImageProportionsForRotation(...) + | are called in right sequence... [X] BUG: keyboard.js, some combinations resolve problems... | in current help shows E, F4, alt-F4 as "Open image in ..." | - E and F4 work OK diff --git a/ui/data.js b/ui/data.js index fcc07143..d4134bd2 100755 --- a/ui/data.js +++ b/ui/data.js @@ -1475,22 +1475,23 @@ function horizontalShiftImage(image, direction){ // the image we are going to move relative to... var target = DATA.ribbons[r][ri + (direction == 'next' ? 1 : -1)] + // we can hit the end or start of the ribbon... if(target == null){ return image } - var order = DATA.order - var i = order.indexOf(gid) - if(i == 0){ - return image - } - var j = order.indexOf(target) - j += (direction == 'next' ? 1 : 0) - - order.splice(i, 1) - order.splice(j, 0, gid) - + // update the order... + // NOTE: this is a critical section and must be done as fast as possible, + // this is why we are using the memory to first do the work and + // then push it in... + // NOTE: in a race condition this may still overwrite the order someone + // else is working on, the data will be consistent... + var order = DATA.order.slice() + order.splice(order.indexOf(gid), 1) + order.splice(order.indexOf(target) + (direction == 'next'? 1 : 0), 0, gid) + // do the dirty work... + DATA.order.splice.apply(DATA.order, [0, DATA.order.length].concat(order)) // just update the ribbons, no reloading needed... updateRibbonOrder(true) diff --git a/ui/keybindings.js b/ui/keybindings.js index 74f2c291..d9f43e0d 100755 --- a/ui/keybindings.js +++ b/ui/keybindings.js @@ -160,6 +160,61 @@ var KEYBOARD_CONFIG = { }, + // ribbon mode only... + // + '.viewer:not(.overlay):not(.single-image-mode)': { + title: 'Ribbon mode', + + Left: { + alt: doc('Shift image left', + function(){ + event.preventDefault() + shiftImageLeft() + centerView(null, 'css') + // XXX for some odd reason centerRibbons does + // something really odd here... + //centerRibbons() + // XXX HACK... + // XXX this still gets misaligned sometimes but this + // is likely due to one of the align bugs + if(window._center_ribbon_delay != null){ + clearTimeout(_center_ribbon_delay) + } + _center_ribbon_delay = setTimeout( + function(){ + centerRibbons() + }, 300) + + return false + }), + }, + Right: { + alt: doc('Shift image right', + function(){ + event.preventDefault() + shiftImageRight() + centerView(null, 'css') + // XXX for some odd reason centerRibbons does + // something really odd here... + //centerRibbons() + // XXX HACK... + // XXX this still gets misaligned sometimes but this + // is likely due to one of the align bugs + // (see: TODO.otl) + if(window._center_ribbon_delay != null){ + clearTimeout(_center_ribbon_delay) + } + _center_ribbon_delay = setTimeout( + function(){ + centerRibbons() + }, 300) + + return false + }), + }, + }, + + // general setup... // '.viewer:not(.overlay)': { @@ -196,25 +251,6 @@ var KEYBOARD_CONFIG = { centerRibbons() }), ctrl: 'prev-screen', - alt: doc('Shift image left', - function(){ - event.preventDefault() - shiftImageLeft() - centerView(null, 'css') - // XXX for some odd reason centerRibbons does - // something really odd here... - //centerRibbons() - // XXX HACK... - // XXX this still gets misaligned sometimes but this - // is likely due to one of the align bugs - if(window._center_ribbon_delay != null){ - clearTimeout(_center_ribbon_delay) - } - _center_ribbon_delay = setTimeout( - function(){ - centerRibbons() - }, 300) - }), }, Right: { default: doc('Next image', @@ -226,26 +262,6 @@ var KEYBOARD_CONFIG = { centerRibbons() }), ctrl: 'next-screen', - alt: doc('Shift image right', - function(){ - event.preventDefault() - shiftImageRight() - centerView(null, 'css') - // XXX for some odd reason centerRibbons does - // something really odd here... - //centerRibbons() - // XXX HACK... - // XXX this still gets misaligned sometimes but this - // is likely due to one of the align bugs - // (see: TODO.otl) - if(window._center_ribbon_delay != null){ - clearTimeout(_center_ribbon_delay) - } - _center_ribbon_delay = setTimeout( - function(){ - centerRibbons() - }, 300) - }), }, 'prev-screen': doc('Previous screen', function(){