tweaking...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-04-18 11:38:28 +03:00
parent 7179d57046
commit c455c21230

View File

@ -68,10 +68,10 @@ var PartialRibbonsActions = actions.Actions({
var loaded = nl + pl + 1 var loaded = nl + pl + 1
// next/prev available... // next/prev available...
// NOTE: we subtract 1 to remove the current and make these // NOTE: we do not include target in counts...
// compatible with: nl, pl var gids = this.data.getImages(target, size, 'total')
var na = this.data.getImages(target, size, 'after').length - 1 var na = gids.slice(gids.indexOf(target)+1).length
var pa = this.data.getImages(target, size, 'before').length - 1 var pa = gids.slice(0, gids.indexOf(target)).length
//console.log(`-- loaded: ${loaded} size: ${size}`) //console.log(`-- loaded: ${loaded} size: ${size}`)
@ -81,18 +81,15 @@ var PartialRibbonsActions = actions.Actions({
// ribbon shorter than we expect... // ribbon shorter than we expect...
|| (loaded < size && na + pa > loaded) || (loaded < size && na + pa > loaded)
|| loaded > size * threshold){ || loaded > size * threshold){
//console.log(`RESIZE: ${loaded} -> ${size}`)
this.resizeRibbon(target, size) this.resizeRibbon(target, size)
// soft-update... // in-place update...
} else if(na + pa < nl + pl
// passed threshold on the right... // passed threshold on the right...
|| (nl < update_threshold && na > nl) } else if((nl < update_threshold && na > nl)
// passed threshold on the left... // passed threshold on the left...
|| (pl < update_threshold && pa > pl) || (pl < update_threshold && pa > pl)
// loaded more than we need by threshold... // loaded more than we need by threshold...
|| nl + pl + 1 > size + update_threshold){ || nl + pl + 1 > size + update_threshold){
//console.log('UPDATE')
r.length == 0 ? r.length == 0 ?
// ribbon not loaded... // ribbon not loaded...
this.resizeRibbon(target, size) this.resizeRibbon(target, size)
@ -100,8 +97,18 @@ var PartialRibbonsActions = actions.Actions({
: this.ribbons : this.ribbons
.preventTransitions(r) .preventTransitions(r)
.updateRibbonInPlace( .updateRibbonInPlace(
this.data.getImages(target, loaded, 'total'), gids,
r_gid, r_gid,
// XXX this makes the animation of the ribbon
// a bit smoother but messes up the indicator
// a bit...
// ...this needs the update process to happen
// very fast comparing to the animation itself
// to stay in sync...
//gids.indexOf(this.current) >= 0 ? 'current' : target)
// XXX STUB: this makes the ribbon animation a bit
// jumpy but does not touch the indicator
// animation...
target) target)
.restoreTransitions(r, true) .restoreTransitions(r, true)
} }
@ -163,10 +170,29 @@ module.PartialRibbons = core.ImageGridFeatures.Feature({
this.updateRibbon(target) this.updateRibbon(target)
}], }],
['resizing.pre', ['resizing.post',
function(unit, size){ function(_, unit, size){
// XXX if(unit == 'scale'){
this.updateRibbon() this.updateRibbon('current', this.screenwidth / size || 1)
} else if(unit == 'screenwidth'){
this.updateRibbon('current', size || 1)
} else if(unit == 'screenheight'){
size = size || 1
// convert target height in ribbons to width in images...
// NOTE: this does not account for compensation that
// .updateRibbon(..) makes for fitting whole image
// counts, this is a small enough error so as not
// to waste time on...
var s = this.ribbons.scale()
var h = this.ribbons.getScreenHeightRibbons()
var w = this.ribbons.getScreenWidthImages()
var nw = w / (h/size)
this.updateRibbon('current', nw)
}
}], }],
], ],
}) })