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:
Alex A. Naanou 2014-11-28 03:57:10 +03:00
parent 4072e95129
commit cf02d3c2d5
3 changed files with 34 additions and 7 deletions

View File

@ -639,6 +639,9 @@ module.MetaActions = {
//
// 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:
// {
@ -668,6 +671,7 @@ module.MetaActions = {
// For more documentation see: Action(..).
//
// XXX add doc, ldoc, tags and save them to each action...
// XXX is .config processing correct here???
var Actions =
module.Actions =
function Actions(a, b){
@ -694,6 +698,11 @@ function Actions(a, b){
if(proto != null){
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

View File

@ -102,6 +102,9 @@ module.setupActions = function(viewer){
var vv = Object.create(v.Viewer)
// XXX need to automate this...
vv.config = Object.create(vv.config || {})
return vv
}

View File

@ -137,14 +137,10 @@ var Client =
module.Client =
actions.Actions({
// XXX should this be here???
config: {
'steps-to-change-direction': 3,
'max-screen-images': 30,
'zoom-step': 1.2,
},
// basic state...
// NOTE: the setters in the following use the appropriate actions
// so to avoid recursion do not use these in the specific
@ -646,6 +642,15 @@ var Viewer =
module.Viewer =
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...
get images(){
@ -967,7 +972,7 @@ actions.Actions(Client, {
this.ribbons.setOrigin()
//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 n = Math.floor(this.ribbons.getScreenWidthImages(s))
@ -978,7 +983,7 @@ actions.Actions(Client, {
this.ribbons.setOrigin()
//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 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,
// 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',
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.updateImage('*')
}],