better approach to hover css

Conflicts:
	builds/4chan-X.user.js
	builds/crx/script.js
This commit is contained in:
ccd0 2014-04-05 20:11:38 -07:00
parent 113dde4eae
commit 74ef633fd7
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 */ /* fixed, z-index */
#overlay, #overlay,
#fourchanx-settings, #fourchanx-settings,
#qp, .ihover, #qp, #ihover,
#navlinks, .fixed #header-bar, #navlinks, .fixed #header-bar,
:root.float #updater, :root.float #updater,
:root.float #thread-stats, :root.float #thread-stats,
@ -124,7 +124,7 @@ div.center:not(.ad-cnt) {
#notifications { #notifications {
z-index: 70; z-index: 70;
} }
#qp, .ihover { #qp, #ihover {
z-index: 60; z-index: 60;
} }
#menu { #menu {
@ -714,19 +714,19 @@ span.hide-announcement {
.fileText:hover .fntrunc, .fileText:hover .fntrunc,
.fileText:not(:hover) .fnfull, .fileText:not(:hover) .fnfull,
.expanded-image > .post > .file > .fileThumb > img[data-md5], .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; display: none;
} }
.expanding { .expanding {
opacity: .5; opacity: .5;
} }
:root.fit-height .full-image { :root.fit-height .full-image:not(#ihover) {
max-height: 100vh; max-height: 100vh;
} }
:root.fit-width .full-image { :root.fit-width .full-image:not(#ihover) {
max-width: 100%; max-width: 100%;
} }
.ihover { #ihover {
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
max-height: 100%; max-height: 100%;

View File

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

View File

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