From 298f18cf70e7f403ba886dcfdbea1d207edebebd Mon Sep 17 00:00:00 2001 From: Tim Lange Date: Mon, 18 Mar 2019 15:57:24 +0100 Subject: [PATCH] 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 --- app/assets/javascripts/discourse/lib/lightbox.js.es6 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/assets/javascripts/discourse/lib/lightbox.js.es6 b/app/assets/javascripts/discourse/lib/lightbox.js.es6 index a259a888e3a..3b3f7b680db 100644 --- a/app/assets/javascripts/discourse/lib/lightbox.js.es6 +++ b/app/assets/javascripts/discourse/lib/lightbox.js.es6 @@ -6,6 +6,7 @@ export default function($elem) { if (!$elem) { return; } + const originalMeta = $("meta[name=viewport]").attr("content"); loadScript("/javascripts/jquery.magnific-popup.min.js").then(function() { const spoilers = $elem.find(".spoiler a.lightbox, .spoiled a.lightbox"); $elem @@ -23,6 +24,10 @@ export default function($elem) { callbacks: { open() { + $("meta[name=viewport]").attr( + "content", + "width=device-width, initial-scale=1.0" + ); const wrap = this.wrap, img = this.currItem.img, maxHeight = img.css("max-height"); @@ -36,6 +41,7 @@ export default function($elem) { }); }, beforeClose() { + $("meta[name=viewport]").attr("content", originalMeta); this.wrap.off("click.pinhandler"); this.wrap.removeClass("mfp-force-scrollbars"); }