-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An image viewer popup for thumbnails and image previews #1325
Conversation
The flexbox thing behind link/image on the viewer is kinda 💩. Play with resize, or wide images, and the button won't stick to the image anymore, and the link will be on the image + on big top/bottom margins. Reason why 2 links btw is because I don't want the black areas around the button to be clickable too. Only image and button are/should be clickable. |
Personally not sure how I feel about the open image button -- I think most people can figure out save as or drag to desktop. Overall great feature. |
👍 on this one, I am currently using the one from bews PR and it works great. what limits the size of the image? can't we make it bigger? I also don't like how the button looks, but I can just change that via css. I definitely am in favor of having such a button since you might want to get to the actual site where that image is coming from (eg. viewing youtube thumbnail and then watching the video) |
client/js/renderPreview.js
Outdated
|
||
// Reason to make this a specific handler is, for images, to open the image | ||
// viewer even when clicking in the margins of the thumbnail | ||
$("#viewport").on("click", ".toggle-content.toggle-type-image", function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried stopPropagation
in this event? It might be possible to get rid of the event above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay that won't work as you want the thumbnail too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll rewrite that part to make it simpler and remove an edge case (accidentally clicking on margin of image in link previews, not image previews, will open the link instead of the viewer).
client/js/renderPreview.js
Outdated
return false; | ||
}); | ||
|
||
$(document).on("click", "#image-viewer", function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can cache #viewport
into a variable and bind all these events on it instead of document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can cache #viewport into a variable
Will do!
bind all these events on it instead of document.
Any benefits? By not binding on body
, it means your focus can be off and not catch the event, no?
|
||
$(document).keydown(function(e) { | ||
switch (e.keyCode ? e.keyCode : e.which) { | ||
case 27: // Escape |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also do this dropdown menus, might be a good idea to combine or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really want to get into keyboard handling as part of this PR. Can we do it later?
(Also, I'm not 100% sure we should, hesitating a bit, let's postpone this I'd say)
I disagree, let's not make assumptions on that sort of level, not everyone knows these things. I would however suggest that maybe instead of this button, we could have a button that has this icon which opens it in a new tab. But that's just a small thing. I'll do a proper review of this soon, looks good in general, @astorije |
I don't think using blur (especially with transition) is worth the performance hit considering how dark the container already is. For some reason |
A lot of the time instead of using https://codepen.io/imprakash/pen/GgNMXO Could that be a better solution, @xPaw? |
Additionally to what @YaManicKill said, it's less trivial on mobile to open context menu than to click on a button, and while it's convenient it's not obvious that image is clickable.
Image is: fluid until 100% of the image width max. So if image is 1000px width and your screen is 2000px wide, image will take half of it. If your screen is 500px wide, image will be reduced to fit 100% of the screen.
Yeah, that's the issue I was mentioning above. I think I found a way to fix this, I'll try this and see what happens.
You don't like nice things :D |
If I understand correctly, this is doing both. It looks pretty slick as is! |
e170783
to
1602c28
Compare
I fixed both issues mentioned in the PR description so this should be good for review. The @xPaw, I couldn't find where to check that GPU is being leverage, could you advise? |
1602c28
to
89d949b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, pretty simple. I think I'd like the icon to be as I described in my earlier comment, but it's not a blocker. Nice feature.
|
||
/* Image viewer */ | ||
|
||
// FIXME Remove #input focus when this is open |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you aren't going to fix this in this PR (which I'm ok with) then stick up an issue on github for it and put in the number here. Otherwise this will get missed. I hate random "FIXME" and "TODO" s that don't have any number attached to them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, here it is: #1342
opacity: 1; | ||
} | ||
|
||
#image-viewer .image-link img { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't actual padding on here work instead of using calc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, left/right padding calc was unnecessary as the link itself has a margin
(I removed them), but for the max height, padding doesn't help. What this means is that the image's max height must be all screen minus its margins and the button height, and I can't get to anything else that would work and be less "hardcoded"... :/
client/js/renderPreview.js
Outdated
return false; | ||
}); | ||
|
||
$(document).on("click", "#image-viewer", function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure the way you're binding the event here does not help and $("#image-viewer").on("click")
should work exactly the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, done.
client/js/renderPreview.js
Outdated
type: link.parent().hasClass("toggle-type-image") ? "image" : "link" | ||
})); | ||
|
||
$("body").addClass("image-viewer-opened"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use $(document.body)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, done.
client/js/renderPreview.js
Outdated
$("body").addClass("image-viewer-opened"); | ||
} | ||
|
||
function closeImageViewer() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clearing out image-viewer
in here might be a good idea to unload it from memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, done (after transition has ended).
ae3064f
to
b19b799
Compare
I believe I have addressed all comments. |
b19b799
to
511b173
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@astorije, merge whenever.
An image viewer popup for thumbnails and image previews
Inspired from #1130 for the styling, with some improved logic like support for Escape key.
TODOs
NB: Not sure why, but when I switched to this it fixed the image preview shrinking on
master
🎉