mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-11-01 03:40:09 +00:00
fixed bug in load/reload...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
e20f337978
commit
b420c007bc
@ -1071,8 +1071,6 @@ module.DataPrototype = {
|
||||
// -> data
|
||||
//
|
||||
// NOTE: if mode is 'vertical' then place is ignored...
|
||||
//
|
||||
// XXX needs testing...
|
||||
gatherImages: function(gids, reference, place, mode){
|
||||
gids = this.makeSparseImages(gids)
|
||||
|
||||
@ -1197,6 +1195,7 @@ module.DataPrototype = {
|
||||
// NOTE: .getImage(..) defaults to 'before' thus this to defaults
|
||||
// to 'after'
|
||||
//
|
||||
// XXX needs better docs...
|
||||
shiftImage: function(from, target, mode, direction){
|
||||
from = from == null || from == 'current' ? this.current : from
|
||||
from = from.constructor !== Array ? [from] : from
|
||||
|
||||
@ -989,11 +989,14 @@ module.RibbonsPrototype = {
|
||||
//
|
||||
// ribbons must be .getRibbon(..) compatible.
|
||||
//
|
||||
// reference must be .getImage(..) compatible.
|
||||
// reference must be .getImage(..) compatible or null to disable
|
||||
// offset compensation.
|
||||
//
|
||||
// XXX should this compensate for load offset???
|
||||
// XXX need to make this animation-neutral...
|
||||
updateRibbon: function(gids, ribbon, reference){
|
||||
// NOTE: this will change ribbon size and compensate for it, but this
|
||||
// will not disable transitions, which at this point is the
|
||||
// responsibility of the caller...
|
||||
// NOTE: offset calculation depends on image blocks being square...
|
||||
updateRibbon: function(gids, ribbon, reference, count){
|
||||
var that = this
|
||||
// get/create the ribbon...
|
||||
var r = this.getRibbon(ribbon)
|
||||
@ -1006,12 +1009,10 @@ module.RibbonsPrototype = {
|
||||
var unload = $()
|
||||
|
||||
// compensate for new/removed images...
|
||||
// XXX need to make this animation-neutral...
|
||||
if(reference != null){
|
||||
var ref = this.getImage(reference)
|
||||
|
||||
// align only if ref is loaded...
|
||||
// XXX
|
||||
if(ref.length > 0){
|
||||
var gid = this.getElemGID(ref)
|
||||
var w = ref.outerWidth()
|
||||
@ -1074,13 +1075,6 @@ module.RibbonsPrototype = {
|
||||
that.updateImage(img)
|
||||
})
|
||||
|
||||
/*
|
||||
// remove the rest of the stuff in ribbon...
|
||||
if(loaded.length > gids.length){
|
||||
loaded.eq(gids.length-1).nextAll().remove()
|
||||
}
|
||||
*/
|
||||
|
||||
return this
|
||||
},
|
||||
|
||||
@ -1134,10 +1128,13 @@ module.RibbonsPrototype = {
|
||||
// load the data...
|
||||
var that = this
|
||||
|
||||
// place images...
|
||||
// update ribbons -- place images...
|
||||
if(data.ribbons != null){
|
||||
// see if we've got a custom ribbon updater...
|
||||
var updateRibbon = settings.updateRibbon || this.updateRibbon.bind(this)
|
||||
|
||||
Object.keys(data.ribbons).forEach(function(gid){
|
||||
that.updateRibbon(data.ribbons[gid], gid)
|
||||
updateRibbon(data.ribbons[gid], gid)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -85,12 +85,6 @@ module.setupActions = function(viewer){
|
||||
|
||||
var vv = Object.create(v.Viewer)
|
||||
|
||||
vv.load({
|
||||
data: data.Data(module.mock_data),
|
||||
viewer: viewer,
|
||||
images: makeTestImages(),
|
||||
})
|
||||
|
||||
return vv
|
||||
}
|
||||
|
||||
|
||||
@ -197,6 +197,15 @@ $(function(){
|
||||
//module.GLOBAL_KEYBOARD.__proto__ = a
|
||||
|
||||
|
||||
// load some testing data...
|
||||
a.load({
|
||||
data: data.Data(testing.mock_data),
|
||||
viewer: $('.viewer'),
|
||||
images: testing.makeTestImages(),
|
||||
})
|
||||
|
||||
|
||||
|
||||
// setup base keyboard for devel, in case something breaks...
|
||||
$(document)
|
||||
.keydown(
|
||||
|
||||
@ -538,18 +538,24 @@ actions.Actions(Client, {
|
||||
this.reload()
|
||||
}
|
||||
}],
|
||||
// XXX make this better support partial data view...
|
||||
// ...at this point this first loads the full data and then
|
||||
// .focusImage(..) triggers a reload...
|
||||
// NOTE: this will pass the .ribbons.updateData(..) a custom ribbon
|
||||
// updater if one is defined here as .updateRibbon(target)
|
||||
// XXX actions.updateRibbon(..) and ribbons.updateRibbon(..) are NOT
|
||||
// signature compatible...
|
||||
reload: ['Reload viewer',
|
||||
function(){
|
||||
this.ribbons.preventTransitions()
|
||||
|
||||
return function(){
|
||||
this.ribbons.updateData(this.data)
|
||||
// see if we've got a custom ribbon updater...
|
||||
var that = this
|
||||
var settings = this.updateRibbon != null
|
||||
? { updateRibbon: function(_, ribbon){ that.updateRibbon(ribbon) } }
|
||||
: null
|
||||
|
||||
this.ribbons.updateData(this.data, settings)
|
||||
this.focusImage()
|
||||
|
||||
//this.ribbons.restoreTransitions(true)
|
||||
this.ribbons.restoreTransitions()
|
||||
}
|
||||
}],
|
||||
@ -560,7 +566,6 @@ actions.Actions(Client, {
|
||||
delete this.ribbons
|
||||
}],
|
||||
|
||||
|
||||
// XXX move this to a viewer window action set
|
||||
close: ['Cloase viewer',
|
||||
function(){
|
||||
@ -925,7 +930,16 @@ function Feature(obj){
|
||||
var PartialRibbonsActions =
|
||||
module.PartialRibbonsActions =
|
||||
actions.Actions({
|
||||
updateRibbonSize: ['Update partial ribbon size',
|
||||
/*
|
||||
// NOTE: this is here for documentation only, mixing-this into an
|
||||
// action set will overload the original config...
|
||||
config: {
|
||||
'ribbon-size-screens': 5,
|
||||
'ribbon-resize-threshold': 1,
|
||||
},
|
||||
*/
|
||||
|
||||
updateRibbon: ['Update partial ribbon size',
|
||||
function(target, w, size, threshold){
|
||||
target = target instanceof jQuery
|
||||
? this.ribbons.getElemGID(target)
|
||||
@ -953,6 +967,8 @@ actions.Actions({
|
||||
var na = this.data.getImages(target, s/2, 'after').length - 1
|
||||
var pa = this.data.getImages(target, s/2, 'before').length - 1
|
||||
|
||||
|
||||
// do the update...
|
||||
// the target is not loaded...
|
||||
if(this.ribbons.getImage(target).length == 0
|
||||
// passed threshold on the right...
|
||||
@ -1008,17 +1024,17 @@ module.PartialRibbons = Feature({
|
||||
|
||||
return actions
|
||||
.on('focusImage.pre centerImage.pre', this.tag, function(target){
|
||||
this.updateRibbonSize(target)
|
||||
this.updateRibbon(target)
|
||||
})
|
||||
.on('fitImage.pre', this.tag, function(n){
|
||||
this.updateRibbonSize('current', n || 1)
|
||||
this.updateRibbon('current', n || 1)
|
||||
})
|
||||
.on('fitRibbon.pre', this.tag, function(n){
|
||||
n = n || 1
|
||||
|
||||
// convert target height in ribbons to width in images...
|
||||
// NOTE: this does not account for compensation that
|
||||
// .updateRibbonSize(..) makes for fitting whole image
|
||||
// .updateRibbon(..) makes for fitting whole image
|
||||
// counts, this is a small enough error so as not
|
||||
// to waste time on...
|
||||
var s = this.ribbons.getScale()
|
||||
@ -1026,7 +1042,7 @@ module.PartialRibbons = Feature({
|
||||
var w = this.ribbons.getScreenWidthImages()
|
||||
var nw = w / (h/n)
|
||||
|
||||
this.updateRibbonSize('current', nw)
|
||||
this.updateRibbon('current', nw)
|
||||
})
|
||||
},
|
||||
remove: function(actions){
|
||||
@ -1051,7 +1067,7 @@ module.AlignRibbonsToImageOrder = Feature({
|
||||
this.alignByOrder(target)
|
||||
})
|
||||
// normalize the initial state...
|
||||
.focusImage()
|
||||
//.focusImage()
|
||||
},
|
||||
})
|
||||
|
||||
@ -1069,7 +1085,7 @@ module.AlignRibbonsToFirstImage = Feature({
|
||||
this.alignByFirst(target)
|
||||
})
|
||||
// normalize the initial state...
|
||||
.focusImage()
|
||||
//.focusImage()
|
||||
},
|
||||
})
|
||||
|
||||
@ -1345,7 +1361,7 @@ module.CurrentImageIndicator = Feature({
|
||||
})
|
||||
// turn the marker on...
|
||||
// XXX not sure about this...
|
||||
.focusImage()
|
||||
//.focusImage()
|
||||
},
|
||||
remove: function(actions){
|
||||
actions.viewer.find('.' + this.tag).remove()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user