refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-04-02 22:53:56 +03:00
parent 83d3df856c
commit 436fd80440
2 changed files with 56 additions and 27 deletions

View File

@ -86,7 +86,55 @@ var core = require('features/core')
//
// XXX should this be an action???
function updateImageProportions(){
// XXX
var viewer = this.ribbons.viewer
var image = viewer.find('.image')
var W = viewer.width()
var H = viewer.height()
var w = image.width()
var h = image.height()
var R = W/H
var r = w/h
var threshold = 3
var scale = Math.min(this.screenwidth, this.screenheight)
// XXX the idea is that:
// - up until a specific threshold:
// r is 1
// we do not care about R
// XXX how do we define the threshold???
// - above that threshold:
// r tends to R relative to ???
// - when W == w && H == h
// r == R
// - beyond
// r tends to actual image proportions
// - when (W == w || H == h) && r == actual image proportions
// we change nothing...
// reset image proportions to square...
if(scale > threshold){
image.css({
width: '',
height: '',
})
// shift image container proportions between 1 and R, from threshold
// scale to 1...
} else if(scale >= 1){
// XXX
// shift image container proportions between R and actual image
// proportions...
} else if(W != w || H != h){
// XXX
// image container proportions are the same as image proportions...
} else {
// XXX
}
}

View File

@ -1277,9 +1277,12 @@ var RibbonsPrototype = {
// NOTE: this will make images load without a blackout...
var img = new Image()
img.onload = function(){
image.css({
'background-image': 'url("'+ url +'")',
})
var i = image[0]
i.style.backgroundImage = 'url("'+ url +'")',
// NOTE: these do not account for rotation...
i.setAttribute('preview-width', img.width)
i.setAttribute('preview-height', img.height)
}
img.src = url
return img
@ -1379,7 +1382,7 @@ var RibbonsPrototype = {
// error, recursive group...
if(seen.indexOf(img_data.id) >= 0){
img_data = images.IMAGE_DATA
console.error('Recursice group:', gid)
console.error('Recursive group:', gid)
break
}
seen.push(img_data.id)
@ -1387,28 +1390,6 @@ var RibbonsPrototype = {
img_data = that.images[img_data.cover]
}
/* XXX does not seem to be needing this...
// set the current class...
if(gid == DATA.current){
image.addClass('current')
} else {
image.removeClass('current')
}
*/
/*
// main attrs...
image
.attr({
orientation: [null, 0].indexOf(img_data.orientation) < 0
? img_data.orientation,
: null
flipped: img_data.flipped != null
? img_data.flipped.join(', '),
: null
})
*/
// image state...
that.rotateImage(image, img_data.orientation == null ? 0 : img_data.orientation)
that.flipImage(image, img_data.flipped == null ? [] : img_data.flipped)