mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
more tweaking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
12267b7be8
commit
53c1614c82
@ -429,7 +429,7 @@ var KeyboardActions = actions.Actions({
|
|||||||
// limit key repeat to one per N milliseconds.
|
// limit key repeat to one per N milliseconds.
|
||||||
//
|
//
|
||||||
// Set this to -1 or null to run keys without any limitations.
|
// Set this to -1 or null to run keys without any limitations.
|
||||||
'max-key-repeat-rate': 0,
|
'keyboard-max-key-repeat-rate': 0,
|
||||||
|
|
||||||
// The amount of keyboard "quiet" time to wait for when
|
// The amount of keyboard "quiet" time to wait for when
|
||||||
// .pauseKeyboardRepeat(..) is called...
|
// .pauseKeyboardRepeat(..) is called...
|
||||||
@ -726,8 +726,8 @@ var KeyboardActions = actions.Actions({
|
|||||||
|
|
||||||
// setup base keyboard for devel, in case something breaks...
|
// setup base keyboard for devel, in case something breaks...
|
||||||
// This branch does not drop keys...
|
// This branch does not drop keys...
|
||||||
if(this.config['max-key-repeat-rate'] < 0
|
if(this.config['keyboard-max-key-repeat-rate'] < 0
|
||||||
|| this.config['max-key-repeat-rate'] == null){
|
|| this.config['keyboard-max-key-repeat-rate'] == null){
|
||||||
this.__keyboard_handler = handler
|
this.__keyboard_handler = handler
|
||||||
|
|
||||||
// drop keys if repeating too fast...
|
// drop keys if repeating too fast...
|
||||||
@ -738,7 +738,7 @@ var KeyboardActions = actions.Actions({
|
|||||||
keyboard.dropRepeatingkeys(
|
keyboard.dropRepeatingkeys(
|
||||||
handler,
|
handler,
|
||||||
function(){
|
function(){
|
||||||
return that.config['max-key-repeat-rate'] })
|
return that.config['keyboard-max-key-repeat-rate'] })
|
||||||
}
|
}
|
||||||
|
|
||||||
target.keydown(handler)
|
target.keydown(handler)
|
||||||
|
|||||||
@ -313,7 +313,7 @@ module.CurrentImageIndicator = core.ImageGridFeatures.Feature({
|
|||||||
// ...still not sure why .preventTransitions(m) did not
|
// ...still not sure why .preventTransitions(m) did not
|
||||||
// do the job.
|
// do the job.
|
||||||
['resizeRibbon.pre',
|
['resizeRibbon.pre',
|
||||||
function(target, s){
|
function(target){
|
||||||
var m = this.ribbons.viewer.find('.current-marker')
|
var m = this.ribbons.viewer.find('.current-marker')
|
||||||
var c = this.current
|
var c = this.current
|
||||||
var r = this.current_ribbon
|
var r = this.current_ribbon
|
||||||
|
|||||||
@ -29,6 +29,13 @@ var PartialRibbonsActions = actions.Actions({
|
|||||||
|
|
||||||
// Sets size of ribbons in single image mode...
|
// Sets size of ribbons in single image mode...
|
||||||
'ribbons-resize-single-image': 21,
|
'ribbons-resize-single-image': 21,
|
||||||
|
|
||||||
|
// can be:
|
||||||
|
// 'hybrid'
|
||||||
|
// 'resize'
|
||||||
|
'ribbons-in-place-update-mode': 'resize',
|
||||||
|
|
||||||
|
'ribbons-in-place-update-timeout': 200,
|
||||||
},
|
},
|
||||||
|
|
||||||
updateRibbon: ['- Interface/Update partial ribbon size',
|
updateRibbon: ['- Interface/Update partial ribbon size',
|
||||||
@ -85,107 +92,40 @@ var PartialRibbonsActions = actions.Actions({
|
|||||||
|| loaded > size * threshold){
|
|| loaded > size * threshold){
|
||||||
//console.log('RESIZE')
|
//console.log('RESIZE')
|
||||||
this.resizeRibbon(target, size)
|
this.resizeRibbon(target, size)
|
||||||
//*/
|
|
||||||
|
|
||||||
/*/ XXX long jump condition......
|
// more complex cases...
|
||||||
if(img.length != 0
|
|
||||||
&& (r.length == 0
|
|
||||||
// ribbon shorter than we expect...
|
|
||||||
|| (loaded < size && na + pa > loaded)
|
|
||||||
// ribbon too long...
|
|
||||||
|| loaded > size * threshold)){
|
|
||||||
console.log('RESIZE')
|
|
||||||
this.resizeRibbon(target, size)
|
|
||||||
|
|
||||||
// image is off screen -- align off then animate...
|
|
||||||
// 1) initial state
|
|
||||||
// T <- [---|---x---|---------------]
|
|
||||||
// 2) load new state but align off screen
|
|
||||||
// [-------T-------|-------|---]
|
|
||||||
// 3) animate
|
|
||||||
// [---|---T---|---------------]
|
|
||||||
// XXX this makes the draw worse...
|
|
||||||
} else if(img.length == 0 ){
|
|
||||||
console.log('LONG-JUMP')
|
|
||||||
r.length == 0 ?
|
|
||||||
// ribbon not loaded...
|
|
||||||
this.resizeRibbon(target, size)
|
|
||||||
// simply update...
|
|
||||||
: this.ribbons
|
|
||||||
.preventTransitions(r)
|
|
||||||
.updateRibbonInPlace(
|
|
||||||
gids,
|
|
||||||
r_gid,
|
|
||||||
data.getImageOrder(this.current) > data.getImageOrder(target) ?
|
|
||||||
gids[gids.length - w]
|
|
||||||
: gids[w])
|
|
||||||
.restoreTransitions(r, true)
|
|
||||||
//*/
|
|
||||||
|
|
||||||
// in-place update...
|
|
||||||
// passed threshold on the right...
|
// passed threshold on the right...
|
||||||
} else if((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')
|
var t = Date.now()
|
||||||
// resize...
|
// resize mode...
|
||||||
if(r.length == 0
|
if(this.config['ribbons-in-place-update-mode'] == 'resize'
|
||||||
|| (this.toggleSingleImage
|
// no ribbon loaded...
|
||||||
&& this.toggleSingleImage('?') == 'on')){
|
|| r.length == 0
|
||||||
|
// only if we are going slow...
|
||||||
|
|| t - (this.__last_update || 0)
|
||||||
|
> (this.config['ribbons-in-place-update-timeout'] || 200)
|
||||||
|
// full screen...
|
||||||
|
|| (this.toggleSingleImage
|
||||||
|
&& this.toggleSingleImage('?') == 'on')){
|
||||||
|
//console.log('RESIZE')
|
||||||
this.resizeRibbon(target, size)
|
this.resizeRibbon(target, size)
|
||||||
|
|
||||||
// simply update...
|
// in-place update...
|
||||||
} else {
|
} else {
|
||||||
// preload...
|
//console.log('UPDATE')
|
||||||
var c = gids.indexOf(data.getImage('current', r_gid))
|
var c = gids.indexOf(data.getImage('current', r_gid))
|
||||||
var t = gids.indexOf(target)
|
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...
|
ribbons
|
||||||
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(gids, r_gid, target)
|
||||||
//.updateRibbon(
|
|
||||||
gids,
|
|
||||||
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)
|
|
||||||
.restoreTransitions(r, true)
|
.restoreTransitions(r, true)
|
||||||
}
|
}
|
||||||
|
this.__last_update = t
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1642,6 +1642,7 @@ var RibbonsPrototype = {
|
|||||||
var that = this
|
var that = this
|
||||||
var r = this.getRibbon(ribbon)
|
var r = this.getRibbon(ribbon)
|
||||||
var loaded = r.find(IMAGE)
|
var loaded = r.find(IMAGE)
|
||||||
|
gids = gids.slice(0, loaded.length)
|
||||||
|
|
||||||
// update offset...
|
// update offset...
|
||||||
if(reference != null){
|
if(reference != null){
|
||||||
@ -1665,10 +1666,8 @@ var RibbonsPrototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update gids...
|
// update gids...
|
||||||
//var update = []
|
|
||||||
var unload_marks = []
|
var unload_marks = []
|
||||||
gids
|
gids
|
||||||
.slice(0, loaded.length)
|
|
||||||
.forEach(function(gid, i){
|
.forEach(function(gid, i){
|
||||||
if(gid !== undefined){
|
if(gid !== undefined){
|
||||||
var img = loaded.eq(i)
|
var img = loaded.eq(i)
|
||||||
@ -1679,18 +1678,14 @@ var RibbonsPrototype = {
|
|||||||
unload_marks.concat(that.getImageMarks(g).toArray())
|
unload_marks.concat(that.getImageMarks(g).toArray())
|
||||||
: unload_marks
|
: unload_marks
|
||||||
|
|
||||||
gid
|
// XXX for some reason this is smoother than:
|
||||||
&& that.setElemGID(img, gid)
|
// gid && that.updateImage(img, gid)
|
||||||
//&& update.push(img[0])
|
gid && that.updateImage(that.setElemGID(img, gid))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
$(unload_marks)
|
$(unload_marks)
|
||||||
.remove()
|
.remove()
|
||||||
|
|
||||||
// update images...
|
|
||||||
this.updateImage(loaded)
|
|
||||||
//this.updateImage($(update))
|
|
||||||
|
|
||||||
return this
|
return this
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user