mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
83d3df856c
commit
436fd80440
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user