Skip to content
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

Fix #91: Allow Zoom In, into images #6474

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ HumHub Changelog
- Fix #6468: Module Administration - Marketplace Links broken without Pretty URLs
- Enh #6469: Added Info text for Marketplace page
- Fix #112: Reorder Table Rows
- Fix #91: Allow Zoom In, into images

1.15.0-beta.1 (July 31, 2023)
-----------------------------
Expand Down
25 changes: 23 additions & 2 deletions static/js/humhub/humhub.ui.gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
* @param {type} param2
*/
humhub.module('ui.gallery', function (module, require, $) {
var lastTap = 0;
var timeout;

var init = function () {
$(document).on('click.humhub:ui:gallery', '[data-ui-gallery]', function (evt) {
var $this = $(this);

if($this.is('img') && $this.closest('a').length) {
if ($this.is('img') && $this.closest('a').length) {
return;
}

Expand All @@ -20,11 +22,30 @@ humhub.module('ui.gallery', function (module, require, $) {
var $links = (gallery) ? $('[data-ui-gallery="' + gallery + '"]') : $this.parent().find('[data-ui-gallery]');
var options = {index: $this[0], event: evt.originalEvent};

if($this.is('img')) {
if ($this.is('img')) {
options['urlProperty'] = 'src';
}
blueimp.Gallery($links.get(), options);
});

// Zooming in on small images by double-tap or double-click
$('#blueimp-gallery').on('touchend click', '.slides .slide > img', function (evt) {
var currentTime = new Date().getTime();
var tapLength = currentTime - lastTap;

evt.preventDefault();
clearTimeout(timeout);

if (tapLength < 500 && tapLength > 0) {
$(evt.target).toggleClass('contain-img');
} else {
timeout = setTimeout(function () {
clearTimeout(timeout);
}, 500);
}

lastTap = currentTime;
});
};

module.export({
Expand Down
20 changes: 16 additions & 4 deletions static/less/media.less
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,26 @@
}

#blueimp-gallery {
.slide {
img {
max-height: 80%;
.slides, .slide {
height: 100%;
max-height: 100%;
max-width: 100%;
min-width: 100%;
}

.slide > img {
max-height: 90%;
max-width: 100%;

&.contain-img {
height: 90%;
width: 100%;
object-fit: contain;
object-position: center;
}
}
}


audio, canvas, progress, video {
display: inline-block;
vertical-align: baseline;
Expand Down
2 changes: 1 addition & 1 deletion themes/HumHub/css/theme.css

Large diffs are not rendered by default.