better approach to hover css

This commit is contained in:
ccd0 2014-04-05 20:11:38 -07:00
parent 2a3f7ecd54
commit 904af13063
5 changed files with 46 additions and 58 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -108,7 +108,7 @@ div.center:not(.ad-cnt) {
/* fixed, z-index */
#overlay,
#fourchanx-settings,
#qp, .ihover,
#qp, #ihover,
#navlinks, .fixed #header-bar,
:root.float #updater,
:root.float #thread-stats,
@ -124,7 +124,7 @@ div.center:not(.ad-cnt) {
#notifications {
z-index: 70;
}
#qp, .ihover {
#qp, #ihover {
z-index: 60;
}
#menu {
@ -825,19 +825,19 @@ span.hide-announcement {
.fileText:hover .fntrunc,
.fileText:not(:hover) .fnfull,
.expanded-image > .post > .file > .fileThumb > img[data-md5],
:not(.expanded-image) > .post > .file .full-image {
:not(.expanded-image) > .post > .file .full-image:not(#ihover) {
display: none;
}
.expanding {
opacity: .5;
}
:root.fit-height .full-image {
:root.fit-height .full-image:not(#ihover) {
max-height: 100vh;
}
:root.fit-width .full-image {
:root.fit-width .full-image:not(#ihover) {
max-width: 100%;
}
.ihover {
#ihover {
-moz-box-sizing: border-box;
box-sizing: border-box;
max-height: 100%;

View File

@ -104,25 +104,23 @@ ImageExpand =
return if post.isHidden or post.file.isExpanded or $.hasClass thumb, 'expanding'
$.addClass thumb, 'expanding'
naturalHeight = if isVideo then 'videoHeight' else 'naturalHeight'
if img = post.file.fullImage
if el = post.file.fullImage
# Expand already-loaded/ing picture.
TrashQueue.remove img
$.rmClass img, 'ihover'
$.addClass img, 'full-image'
img.controls = (img.parentNode isnt thumb.parentNode)
$.asap (-> img[naturalHeight]), ->
TrashQueue.remove el
el.controls = (el.parentNode isnt thumb.parentNode)
$.asap (-> el[naturalHeight]), ->
ImageExpand.completeExpand post
return
post.file.fullImage = img = $.el (if isVideo then 'video' else 'img'),
post.file.fullImage = el = $.el (if isVideo then 'video' else 'img'),
className: 'full-image'
src: src or post.file.URL
if isVideo
img.loop = true
img.controls = Conf['Show Controls']
$.on img, 'error', ImageExpand.error
el.loop = true
el.controls = Conf['Show Controls']
$.on el, 'error', ImageExpand.error
$.asap (-> post.file.fullImage[naturalHeight]), ->
ImageExpand.completeExpand post
$.after (if img.controls then thumb.parentNode else thumb), img
$.after (if el.controls then thumb.parentNode else thumb), el
completeExpand: (post) ->
{thumb} = post.file

View File

@ -23,15 +23,14 @@ ImageHover =
if post.file.fullImage
el = post.file.fullImage
TrashQueue.remove el
$.rmClass el, 'full-image'
$.addClass el, 'ihover'
else
el = $.el (if isVideo then 'video' else 'img'),
className: 'ihover'
className: 'full-image'
src: post.file.URL
post.file.fullImage = el
{thumb} = post.file
$.after (if isVideo and Conf['Show Controls'] then thumb.parentNode else thumb), el
el.id = 'ihover'
el.dataset.fullID = post.fullID
if isVideo
el.loop = true
@ -49,8 +48,7 @@ ImageHover =
if isVideo
el.pause()
TrashQueue.add el
$.rmClass el, 'ihover'
$.addClass el, 'full-image'
el.removeAttribute 'id'
$.on el, 'error', ImageHover.error
error: ->
return unless doc.contains @