Commit c63fd5e3 authored by ManuLEM's avatar ManuLEM
Browse files

Render big image with proper size

parent 061ab077
......@@ -1443,6 +1443,11 @@ img.emoji {
transition: all ease-in 0.35s;
}
#largeImagePopup img {
width: 100%;
height: 100%;
}
#tweetConfirmationPopup{
background-color: #595959;
width: 500px;
......
......@@ -736,11 +736,15 @@ Message.prototype.processMedia = function(){
Message.prototype.enlargeImage = function(e){
var srcAttribute = e.target.src;
var src = srcAttribute.substring(0, srcAttribute.lastIndexOf(':'));
var size = srcAttribute.substring(srcAttribute.lastIndexOf(':'), srcAttribute.length);
var fullsize = e.target.attributes[1].value;
var height = fullsize.substring(0, fullsize.lastIndexOf('/'));
var width = fullsize.substring(fullsize.lastIndexOf('/') + 1, fullsize.length);
var height = parseInt(fullsize.substring(0, fullsize.lastIndexOf('/')));
var width = parseInt(fullsize.substring(fullsize.lastIndexOf('/') + 1, fullsize.length));
var differencial = Math.min(window.innerHeight*0.8 / height, window.innerWidth*0.8 / width);
if (differencial < 1) {
height = height*differencial;
width = width*differencial;
}
var popup = document.getElementById('largeImagePopup');
var popupImage = document.querySelector('#largeImagePopup img');
popupImage.setAttribute('src', src + ':large');
......@@ -750,11 +754,14 @@ Message.prototype.enlargeImage = function(e){
// console.log('left: ', left);
popup.style.left = left;
var halfHeight = height / 2;
var height = 'calc(50% - ' + halfHeight + 'px)';
// console.log('height: ', height);
popup.style.top = height;
var top = 'calc(50% - ' + halfHeight + 'px)';
// console.log('top: ', top);
popup.style.top = top;
popup.style.display = 'block';
popup.style.height = height + 'px';
popup.style.width = width + 'px';
function closeImagePopup(e){
columnsList.removeEventListener('click', closeImagePopup, true);
e.stopPropagation();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment