did some cleanup...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-11-25 02:32:47 +04:00
parent bf561c9fa4
commit caa856be79
2 changed files with 7 additions and 40 deletions

View File

@ -1335,6 +1335,9 @@ function getGIDsAround(count, gid, ribbon, data){
// NOTE: this expects that both arrays cleanly intersect each other only // NOTE: this expects that both arrays cleanly intersect each other only
// once... // once...
// XXX this sometimes returns a null and a value which seems to be
// impossible...
// ...this does not affect anything, but still need to investigate...
function getCommonSubArrayOffsets(L1, L2){ function getCommonSubArrayOffsets(L1, L2){
var res = {} var res = {}
@ -1391,7 +1394,7 @@ function loadImagesAround(count, gid, ribbon, data){
ribbon = ribbon == null ? getRibbonIndex() : ribbon ribbon = ribbon == null ? getRibbonIndex() : ribbon
ribbon = typeof(ribbon) != typeof(123) ? getRibbonIndex(ribbon) : ribbon ribbon = typeof(ribbon) != typeof(123) ? getRibbonIndex(ribbon) : ribbon
count = count == null ? Math.round(LOAD_SCREENS * getScreenWidthInImages()) : count count = count == null ? Math.round(LOAD_SCREENS * getScreenWidthInImages()) : count
// get a gid that exists in the current ribbon...
gid = data.ribbons[ribbon].indexOf(gid) < 0 ? getGIDBefore(gid, ribbon, null, data) : gid gid = data.ribbons[ribbon].indexOf(gid) < 0 ? getGIDBefore(gid, ribbon, null, data) : gid
var ribbon_elem = getRibbon(ribbon) var ribbon_elem = getRibbon(ribbon)
@ -1415,23 +1418,10 @@ function loadImagesAround(count, gid, ribbon, data){
var size = getVisibleImageSize('max') var size = getVisibleImageSize('max')
/*
// XXX this means something is REALLY wrong...
// NOTE: if at least one of left or right is null then there might
// be an error loading the ribbons...
if(left == null || right == null){
// XXX this code is temporary...
console.warn('Something is wrong with loaded ribbon #'+ribbon+', reloading...')
left = null
right = null
}
*/
// XXX might be magic but now this appears to work!!!
// no common sections, do a full reload... // no common sections, do a full reload...
//if(left == null && right == null){ // XXX NOTE: we use || instead of && here to compensate for an oddity
// in getCommonSubArrayOffsets(...), see it for further details...
if(left == null || right == null){ if(left == null || right == null){
//console.log('Ribbon #'+ribbon+', reloading...')
var n = new_ribbon.indexOf(gid) var n = new_ribbon.indexOf(gid)
var o = old_ribbon.indexOf(gid) var o = old_ribbon.indexOf(gid)
o = o < 0 ? n : o o = o < 0 ? n : o
@ -1440,14 +1430,6 @@ function loadImagesAround(count, gid, ribbon, data){
var left = n - o var left = n - o
var right = (new_ribbon.length - old_ribbon.length) - left var right = (new_ribbon.length - old_ribbon.length) - left
/*
console.log(' >>>', left, right, '---',
'old:', old_ribbon.length,
'@', o,
'new:', new_ribbon.length,
'@', n)
*/
extendRibbon(left, right, ribbon_elem) extendRibbon(left, right, ribbon_elem)
// update the images... // update the images...
@ -1458,24 +1440,10 @@ function loadImagesAround(count, gid, ribbon, data){
var updated = new_ribbon.length var updated = new_ribbon.length
// partial reload... // partial reload...
// XXX buggy...
// see: BUG: @ 9 image width, jumping to end of ribbon length 39 messes up loading...
} else { } else {
/*
console.log('Ribbon #'+ribbon+', updating...')
console.log(' >>>', left, right, '---',
'old:', old_ribbon.length,
'@', old_ribbon.indexOf(gid),
'new:', new_ribbon.length,
'@', new_ribbon.indexOf(gid))
*/
var res = extendRibbon(left, right, ribbon_elem) var res = extendRibbon(left, right, ribbon_elem)
// XXX this will get all the current images, not the resulting ones... // XXX this will get all the current images, not the resulting ones...
var images = ribbon_elem.find('.image') var images = ribbon_elem.find('.image')
//console.log(' >>> images:', images.length, 'res:', res.left.length, res.right.length)
var updated = 0 var updated = 0
// update the images... // update the images...
@ -1512,6 +1480,7 @@ function loadImagesAround(count, gid, ribbon, data){
// //
// XXX for some magical (unknown) reason this returns BEFORE all the // XXX for some magical (unknown) reason this returns BEFORE all the
// elements this creates actually exist (async)... // elements this creates actually exist (async)...
// ...this causes race conditions...
function loadImages(ref_gid, count, ribbon){ function loadImages(ref_gid, count, ribbon){
ribbon = $(ribbon) ribbon = $(ribbon)
var images = ribbon.find('.image') var images = ribbon.find('.image')

View File

@ -99,8 +99,6 @@ function setupDataBindings(viewer){
// likely due to shifting... // likely due to shifting...
|| ( gr.length > l || ( gr.length > l
&& l < Math.round(screen_size * LOAD_SCREENS))){ && l < Math.round(screen_size * LOAD_SCREENS))){
// XXX in some cases this makes the current ribbon align
// in a wrong way...
//loadImages(gid, Math.round(screen_size * LOAD_SCREENS), ribbon) //loadImages(gid, Math.round(screen_size * LOAD_SCREENS), ribbon)
loadImagesAround(Math.round(screen_size * LOAD_SCREENS), gid, ribbon) loadImagesAround(Math.round(screen_size * LOAD_SCREENS), gid, ribbon)
} }