tweaking and cleanup...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-04-20 01:44:04 +03:00
parent a9cf6f39b6
commit 12267b7be8
3 changed files with 48 additions and 17 deletions

View File

@ -32,7 +32,7 @@ var PartialRibbonsActions = actions.Actions({
}, },
updateRibbon: ['- Interface/Update partial ribbon size', updateRibbon: ['- Interface/Update partial ribbon size',
function(target, w, size, threshold){ function(target, w, size, threshold, preload){
target = target instanceof jQuery target = target instanceof jQuery
? this.ribbons.getElemGID(target) ? this.ribbons.getElemGID(target)
// NOTE: data.getImage(..) can return null at start or end // NOTE: data.getImage(..) can return null at start or end
@ -49,6 +49,7 @@ var PartialRibbonsActions = actions.Actions({
|| this.config['ribbon-resize-threshold'] || this.config['ribbon-resize-threshold']
|| 2) || 2)
var update_threshold = (this.config['ribbon-update-threshold'] || 2) * w var update_threshold = (this.config['ribbon-update-threshold'] || 2) * w
preload = preload === undefined ? true : preload
var data = this.data var data = this.data
var ribbons = this.ribbons var ribbons = this.ribbons
@ -129,19 +130,44 @@ var PartialRibbonsActions = actions.Actions({
// 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') //console.log('UPDATE')
// XXX a bit jumpy, need to make this work sync within
// as close to a single frame as possible...
// XXX .preventTransitions(..) seems not to have the
// desired effect...
// ...might also be a good idea to update the indicator
// or give it an event to update to...
(r.length == 0
|| (this.toggleSingleImage
&& this.toggleSingleImage('?') == 'on')) ?
// resize... // resize...
if(r.length == 0
|| (this.toggleSingleImage
&& this.toggleSingleImage('?') == 'on')){
this.resizeRibbon(target, size) this.resizeRibbon(target, size)
// simply update... // simply update...
: this.ribbons } else {
// preload...
var c = gids.indexOf(data.getImage('current', r_gid))
var t = gids.indexOf(target)
if(preload
// we are going to shift ribbon in view...
&& c >= 0
// the distance is greater than screen width...
&& Math.abs(t - pl) > w){
console.log('PRELOAD')
// preload head...
if(c > t){
preload = gids.slice(0, pl+w)
gids = preload.slice().fill(false)
.concat(gids.slice(pl+w))
// preload tail...
} else {
preload = gids.slice(0, t+w).fill(false)
.concat(gids.slice(t+w))
gids = gids.slice(0, t+w)
}
// XXX this seems to block the animation....
this.ribbons
.updateRibbonInPlace(preload, r_gid)
}
// main update...
this.ribbons
.preventTransitions(r) .preventTransitions(r)
.updateRibbonInPlace( .updateRibbonInPlace(
//.updateRibbon( //.updateRibbon(
@ -160,6 +186,7 @@ var PartialRibbonsActions = actions.Actions({
target) target)
.restoreTransitions(r, true) .restoreTransitions(r, true)
} }
}
}], }],
}) })

View File

@ -1665,6 +1665,7 @@ var RibbonsPrototype = {
} }
// update gids... // update gids...
//var update = []
var unload_marks = [] var unload_marks = []
gids gids
.slice(0, loaded.length) .slice(0, loaded.length)
@ -1678,7 +1679,9 @@ var RibbonsPrototype = {
unload_marks.concat(that.getImageMarks(g).toArray()) unload_marks.concat(that.getImageMarks(g).toArray())
: unload_marks : unload_marks
gid && that.setElemGID(img, gid) gid
&& that.setElemGID(img, gid)
//&& update.push(img[0])
} }
}) })
$(unload_marks) $(unload_marks)
@ -1686,6 +1689,7 @@ var RibbonsPrototype = {
// update images... // update images...
this.updateImage(loaded) this.updateImage(loaded)
//this.updateImage($(update))
return this return this
}, },