Use vh for image expansion's "Fit height" on Chrome and Firefox.

Should give much better performance when resizing for example.
This commit is contained in:
Mayhem 2013-05-21 21:07:41 +02:00
parent a2ac3d73e1
commit b5caa77df8
2 changed files with 10 additions and 6 deletions

View File

@ -532,6 +532,9 @@ a.hide-announcement {
clear: both;
display: table;
}
:root.fit-height .full-image {
max-height: 100vh;
}
:root.fit-width .full-image {
max-width: 100%;
}

View File

@ -51,16 +51,20 @@ ImageExpand =
$.queueTask func, post
return
setFitness: ->
{checked} = @
(if checked then $.addClass else $.rmClass) doc, @name.toLowerCase().replace /\s+/g, '-'
(if @checked then $.addClass else $.rmClass) doc, @name.toLowerCase().replace /\s+/g, '-'
<% if (type === 'userjs') { %>
# XXX Opera doesn't support CSS vh.
return unless @name is 'Fit height'
if checked
if @checked
$.on window, 'resize', ImageExpand.resize
unless ImageExpand.style
ImageExpand.style = $.addStyle null
ImageExpand.resize()
else
$.off window, 'resize', ImageExpand.resize
resize: ->
ImageExpand.style.textContent = ":root.fit-height .full-image {max-height:#{doc.clientHeight}px}"
<% } %>
toggle: (post) ->
{thumb} = post.file
@ -189,6 +193,3 @@ ImageExpand =
$.event 'change', null, input
$.on input, 'change', $.cb.checked
el: label
resize: ->
ImageExpand.style.textContent = ":root.fit-height .full-image {max-height:#{doc.clientHeight}px}"