mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-25 15:00:58 +01:00
Use CSS to resize the lightboxed image instead of Javascript
Summary: We can let the browser do the scaling with some simpler CSS rules. Test Plan: Opened very large images in Safari, Firefox and Chrome and resized the browser. Observed smooth scaling and no issues with the image overlapping UI elements, etc. Reviewers: btrahan, vrana Reviewed By: btrahan CC: aran Maniphest Tasks: T1896 Differential Revision: https://secure.phabricator.com/D3802
This commit is contained in:
parent
9dd9189283
commit
d984a3ffa4
2 changed files with 3 additions and 38 deletions
|
@ -19,7 +19,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.lightbox-attachment img {
|
.lightbox-attachment img {
|
||||||
margin: 50px auto 0;
|
margin: 3% auto 0;
|
||||||
|
max-height: 90%;
|
||||||
|
max-width: 90%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.lightbox-attachment .loading {
|
.lightbox-attachment .loading {
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
* javelin-stratcom
|
* javelin-stratcom
|
||||||
* javelin-dom
|
* javelin-dom
|
||||||
* javelin-mask
|
* javelin-mask
|
||||||
* javelin-vector
|
|
||||||
* javelin-util
|
* javelin-util
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -233,37 +232,7 @@ JX.behavior('lightbox-attachments', function (config) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var img = JX.DOM.find(lightbox, 'img');
|
var img = JX.DOM.find(lightbox, 'img');
|
||||||
var d = JX.Vector.getDim(img);
|
|
||||||
JX.Stratcom.addData(img, { x : d.x, y : d.y } );
|
|
||||||
|
|
||||||
return resizeLightBox(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
function resizeLightBox(e) {
|
|
||||||
if (!lightbox) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var img = JX.DOM.find(lightbox, 'img');
|
|
||||||
var v = JX.Vector.getViewport();
|
|
||||||
var d = JX.Stratcom.getData(img);
|
|
||||||
|
|
||||||
var w = d.x;
|
|
||||||
var h = d.y;
|
|
||||||
var scale = 0;
|
|
||||||
if (w > (v.x - x_margin)) {
|
|
||||||
scale = (v.x - x_margin) / w;
|
|
||||||
w = w * scale;
|
|
||||||
h = h * scale;
|
|
||||||
}
|
|
||||||
if (h > (v.y - y_margin)) {
|
|
||||||
scale = (v.y - y_margin) / h;
|
|
||||||
w = w * scale;
|
|
||||||
h = h * scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
JX.DOM.alterClass(img, 'loading', false);
|
JX.DOM.alterClass(img, 'loading', false);
|
||||||
JX.$V(w, h).setDim(img);
|
|
||||||
JX.Vector.getViewport().setDim(lightbox);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JX.Stratcom.listen(
|
JX.Stratcom.listen(
|
||||||
|
@ -272,12 +241,6 @@ JX.behavior('lightbox-attachments', function (config) {
|
||||||
loadLightBox
|
loadLightBox
|
||||||
);
|
);
|
||||||
|
|
||||||
JX.Stratcom.listen(
|
|
||||||
'resize',
|
|
||||||
null,
|
|
||||||
resizeLightBox
|
|
||||||
);
|
|
||||||
|
|
||||||
JX.Stratcom.listen(
|
JX.Stratcom.listen(
|
||||||
'keydown',
|
'keydown',
|
||||||
null,
|
null,
|
||||||
|
|
Loading…
Reference in a new issue