Getting closer thanks to Urs - sqrt needed

This commit is contained in:
Iam Naughton Phier 2015-02-23 21:19:16 +02:00
parent 57c9eb5950
commit dbb052c666

View file

@ -135,6 +135,7 @@ class @Sahli
@nextpic = => @nextpic = =>
viewbox = $('div#sahliviewer') viewbox = $('div#sahliviewer')
viewbox.children().remove() viewbox.children().remove()
$('#panel').empty()
@scroll_direction = 1 @scroll_direction = 1
@scroll_speed = 5 @scroll_speed = 5
i = @currentpic i = @currentpic
@ -230,14 +231,14 @@ class @Sahli
$('canvas').width newwidth $('canvas').width newwidth
else else
if zoomee.width() != @origwidth if zoomee.width() != @origwidth
zoomee.width @origwidth zoomee.width @origwidthg
$('canvas').width '100%' $('canvas').width '100%'
else else
zoomee.width '100%' zoomee.width '100%'
$('canvas').width '100%' $('canvas').width '100%'
# fix this up so it sets the appropriate width for the columns. # calculate # strips - how many times does window height go into full height
# and then move the canvases into it. # and then move the canvases into it. - done
# outbox toggled last to avoid losing width. (prolly need to fix.) # outbox toggled last to avoid losing width. (prolly need to fix.)
@panelmode = -> @panelmode = ->
$('#panel').toggle() $('#panel').toggle()
@ -245,27 +246,38 @@ class @Sahli
if $('.scrolly').width() == @origwidth if $('.scrolly').width() == @origwidth
$('.scrolly').width '100%' $('.scrolly').width '100%'
$('#panel').empty() $('#panel').empty()
fw = $('body').width() ww = window.innerWidth
fh = window.innerHeight wh = window.innerHeight
numpanels = canvs.length numpanels = canvs.length
hgt = canvs.height() * numpanels fullpicheight = 0
numcols = Math.ceil(hgt / fw) fullpicheight = (fullpicheight + i.height) for i in canvs
amt = fw/numcols
stripe_width = 640
num_strips = Math.sqrt (ww/stripe_width)*(fullpicheight/wh)
numcols = Math.ceil num_strips
scaling_factor = num_strips * wh / fullpicheight
# newheight = canvs[0].height * scaling_factor
# $(canvs[0]).height newheight
newwidth = scaling_factor * canvs.height()
canvs.width newwidth
newheight = $(canvs[0]).height()
colwidth = ww/numcols
outer = $('<div>') outer = $('<div>')
outer.append @createpanel(i,amt - 6) for i in [1..numcols] outer.append @createpanel(i,colwidth - 6) for i in [1..numcols]
outer.addClass 'nosb' outer.addClass 'nosb'
$('#panel').append outer $('#panel').append outer
$('#outbox').toggle() $('#outbox').toggle()
newwidth = Math.floor fw/(numcols+1)
ratio = newwidth / @origwidth
canvs.width newwidth
level = 0 level = 0
drawcol = 1 drawcol = 1
for pic in canvs for pic in canvs
$("#column#{drawcol}").append pic $("#column#{drawcol}").append pic
newheight = pic.height * ratio
level = level + newheight level = level + newheight
if level+newheight > fh+newheight/2 if level+(newheight/2) > wh
level = 0 level = 0
drawcol = drawcol + 1 drawcol = drawcol + 1
@ -278,7 +290,7 @@ class @Sahli
@createpanel = (i,amt) -> @createpanel = (i,amt) ->
dcol = $("<div id='column#{i}'>") dcol = $("<div id='column#{i}'>#{i}</div>")
dcol.addClass 'panelcolumn' dcol.addClass 'panelcolumn'
dcol.width amt dcol.width amt