UX: Enabled pinch to zoom for lightbox (#7161)

* UX: Enabled pinch to zoom for lightbox

* FIX: Prettier for lightbox.js

* FIX: Only change content of meta tag
This commit is contained in:
Tim Lange 2019-03-18 15:57:24 +01:00 committed by Robin Ward
parent 3dfa22b55a
commit 298f18cf70
1 changed files with 6 additions and 0 deletions

View File

@ -6,6 +6,7 @@ export default function($elem) {
if (!$elem) { if (!$elem) {
return; return;
} }
const originalMeta = $("meta[name=viewport]").attr("content");
loadScript("/javascripts/jquery.magnific-popup.min.js").then(function() { loadScript("/javascripts/jquery.magnific-popup.min.js").then(function() {
const spoilers = $elem.find(".spoiler a.lightbox, .spoiled a.lightbox"); const spoilers = $elem.find(".spoiler a.lightbox, .spoiled a.lightbox");
$elem $elem
@ -23,6 +24,10 @@ export default function($elem) {
callbacks: { callbacks: {
open() { open() {
$("meta[name=viewport]").attr(
"content",
"width=device-width, initial-scale=1.0"
);
const wrap = this.wrap, const wrap = this.wrap,
img = this.currItem.img, img = this.currItem.img,
maxHeight = img.css("max-height"); maxHeight = img.css("max-height");
@ -36,6 +41,7 @@ export default function($elem) {
}); });
}, },
beforeClose() { beforeClose() {
$("meta[name=viewport]").attr("content", originalMeta);
this.wrap.off("click.pinhandler"); this.wrap.off("click.pinhandler");
this.wrap.removeClass("mfp-force-scrollbars"); this.wrap.removeClass("mfp-force-scrollbars");
} }