mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-30 02:40:08 +00:00
split .config and added default config inheritance + added fit-overflow option to help controling fitting of images on screen...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
4072e95129
commit
cf02d3c2d5
@ -639,6 +639,9 @@ module.MetaActions = {
|
|||||||
//
|
//
|
||||||
// This will pre-process an object to setup the action mechanics.
|
// This will pre-process an object to setup the action mechanics.
|
||||||
//
|
//
|
||||||
|
// If the this and prototype both contain a .config attribute then this
|
||||||
|
// will make set <actions>.config.__proto__ = <prototype>.config
|
||||||
|
//
|
||||||
//
|
//
|
||||||
// The action format:
|
// The action format:
|
||||||
// {
|
// {
|
||||||
@ -668,6 +671,7 @@ module.MetaActions = {
|
|||||||
// For more documentation see: Action(..).
|
// For more documentation see: Action(..).
|
||||||
//
|
//
|
||||||
// XXX add doc, ldoc, tags and save them to each action...
|
// XXX add doc, ldoc, tags and save them to each action...
|
||||||
|
// XXX is .config processing correct here???
|
||||||
var Actions =
|
var Actions =
|
||||||
module.Actions =
|
module.Actions =
|
||||||
function Actions(a, b){
|
function Actions(a, b){
|
||||||
@ -694,6 +698,11 @@ function Actions(a, b){
|
|||||||
|
|
||||||
if(proto != null){
|
if(proto != null){
|
||||||
obj.__proto__ = proto
|
obj.__proto__ = proto
|
||||||
|
|
||||||
|
// XXX is this the right way to go???
|
||||||
|
if(obj.config != null && proto.config != null){
|
||||||
|
obj.config.__proto__ = proto.config
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj
|
return obj
|
||||||
|
|||||||
@ -102,6 +102,9 @@ module.setupActions = function(viewer){
|
|||||||
|
|
||||||
var vv = Object.create(v.Viewer)
|
var vv = Object.create(v.Viewer)
|
||||||
|
|
||||||
|
// XXX need to automate this...
|
||||||
|
vv.config = Object.create(vv.config || {})
|
||||||
|
|
||||||
return vv
|
return vv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -137,14 +137,10 @@ var Client =
|
|||||||
module.Client =
|
module.Client =
|
||||||
actions.Actions({
|
actions.Actions({
|
||||||
|
|
||||||
// XXX should this be here???
|
|
||||||
config: {
|
config: {
|
||||||
'steps-to-change-direction': 3,
|
'steps-to-change-direction': 3,
|
||||||
'max-screen-images': 30,
|
|
||||||
'zoom-step': 1.2,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
// basic state...
|
// basic state...
|
||||||
// NOTE: the setters in the following use the appropriate actions
|
// NOTE: the setters in the following use the appropriate actions
|
||||||
// so to avoid recursion do not use these in the specific
|
// so to avoid recursion do not use these in the specific
|
||||||
@ -646,6 +642,15 @@ var Viewer =
|
|||||||
module.Viewer =
|
module.Viewer =
|
||||||
actions.Actions(Client, {
|
actions.Actions(Client, {
|
||||||
|
|
||||||
|
config: {
|
||||||
|
'max-screen-images': 30,
|
||||||
|
|
||||||
|
'zoom-step': 1.2,
|
||||||
|
|
||||||
|
// added to number of images to fit to indicate scroll ability...
|
||||||
|
'fit-overflow': 0.2,
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Images...
|
// Images...
|
||||||
get images(){
|
get images(){
|
||||||
@ -967,7 +972,7 @@ actions.Actions(Client, {
|
|||||||
this.ribbons.setOrigin()
|
this.ribbons.setOrigin()
|
||||||
|
|
||||||
//var n = Math.round(this.ribbons.getScreenWidthImages())-1
|
//var n = Math.round(this.ribbons.getScreenWidthImages())-1
|
||||||
var d = this.config['zoom-step']
|
var d = this.config['zoom-step'] || 1.2
|
||||||
var s = a.ribbons.getScale() * d
|
var s = a.ribbons.getScale() * d
|
||||||
var n = Math.floor(this.ribbons.getScreenWidthImages(s))
|
var n = Math.floor(this.ribbons.getScreenWidthImages(s))
|
||||||
|
|
||||||
@ -978,7 +983,7 @@ actions.Actions(Client, {
|
|||||||
this.ribbons.setOrigin()
|
this.ribbons.setOrigin()
|
||||||
|
|
||||||
//var n = Math.round(this.ribbons.getScreenWidthImages())+1
|
//var n = Math.round(this.ribbons.getScreenWidthImages())+1
|
||||||
var d = this.config['zoom-step']
|
var d = this.config['zoom-step'] || 1.2
|
||||||
var s = a.ribbons.getScale() / d
|
var s = a.ribbons.getScale() / d
|
||||||
var n = Math.ceil(this.ribbons.getScreenWidthImages(s))
|
var n = Math.ceil(this.ribbons.getScreenWidthImages(s))
|
||||||
|
|
||||||
@ -993,8 +998,18 @@ actions.Actions(Client, {
|
|||||||
}],
|
}],
|
||||||
// NOTE: if this gets a count argument it will fit count images,
|
// NOTE: if this gets a count argument it will fit count images,
|
||||||
// default is one.
|
// default is one.
|
||||||
|
// NOTE: this will add .config['fit-overflow'] to odd counts if no
|
||||||
|
// overflow if passed.
|
||||||
|
// ...this is done to add ability to control scroll indication.
|
||||||
fitImage: ['Fit image',
|
fitImage: ['Fit image',
|
||||||
function(count){
|
function(count, overflow){
|
||||||
|
if(count != null){
|
||||||
|
overflow = overflow == false ? 0 : overflow
|
||||||
|
var o = overflow != null ? overflow
|
||||||
|
: count % 2 != 1 ? 0
|
||||||
|
: (this.config['fit-overflow'] || 0)
|
||||||
|
count += o
|
||||||
|
}
|
||||||
this.ribbons.fitImage(count)
|
this.ribbons.fitImage(count)
|
||||||
this.ribbons.updateImage('*')
|
this.ribbons.updateImage('*')
|
||||||
}],
|
}],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user