Fix lightbox resizing
This commit is contained in:
@@ -337,6 +337,8 @@
|
|||||||
, type: $link.attr('data-type')
|
, type: $link.attr('data-type')
|
||||||
, id: $link.attr('data-id')
|
, id: $link.attr('data-id')
|
||||||
, $Media: $link.attr('data-type')=='video'?self.$video:self.$image
|
, $Media: $link.attr('data-type')=='video'?self.$video:self.$image
|
||||||
|
, width: $link.find('img').attr('width')
|
||||||
|
, height: $link.find('img').attr('height')
|
||||||
//ADDED-END
|
//ADDED-END
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -506,15 +508,11 @@
|
|||||||
// When image to show is preloaded, we send the width and height to sizeContainer()
|
// When image to show is preloaded, we send the width and height to sizeContainer()
|
||||||
var preloader = new Image();
|
var preloader = new Image();
|
||||||
preloader.onload = function(){
|
preloader.onload = function(){
|
||||||
var $preloader;
|
|
||||||
|
|
||||||
self.$image.attr({
|
self.$image.attr({
|
||||||
'alt': self.album[imageNumber].alt,
|
'alt': self.album[imageNumber].alt,
|
||||||
'src': filename
|
'src': filename
|
||||||
});
|
});
|
||||||
|
|
||||||
$preloader = $(preloader);
|
|
||||||
|
|
||||||
//Orientation management
|
//Orientation management
|
||||||
if(Math.abs(self.album[imageNumber].orientation) == 90 && preloader.width > preloader.height) {
|
if(Math.abs(self.album[imageNumber].orientation) == 90 && preloader.width > preloader.height) {
|
||||||
var sWidth = preloader.width;
|
var sWidth = preloader.width;
|
||||||
@@ -557,15 +555,20 @@
|
|||||||
}, 0);
|
}, 0);
|
||||||
*/
|
*/
|
||||||
if(e) {
|
if(e) {
|
||||||
var oMedia = this.album[this.currentImageIndex];
|
|
||||||
if(oMedia.type == 'image') {
|
|
||||||
if(typeof oResizeTimer != 'undefined') clearTimeout(oResizeTimer);
|
if(typeof oResizeTimer != 'undefined') clearTimeout(oResizeTimer);
|
||||||
oResizeTimer = setTimeout(()=>{this.changeImage(this.currentImageIndex);}, 200);
|
oResizeTimer = setTimeout(
|
||||||
}
|
() => {
|
||||||
else {
|
switch(this.album[this.currentImageIndex].type) {
|
||||||
//var $Media = oMedia.$Media;
|
case 'image':
|
||||||
//this.updateSize($($Media), $Media.videoWidth, $Media.videoHeight, oMedia.type);
|
this.changeImage(this.currentImageIndex);
|
||||||
|
break;
|
||||||
|
case 'video':
|
||||||
|
this.updateSize(this.currentImageIndex);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
200
|
||||||
|
);
|
||||||
}
|
}
|
||||||
//ADDED-END
|
//ADDED-END
|
||||||
};
|
};
|
||||||
@@ -710,11 +713,11 @@
|
|||||||
|
|
||||||
// Preload previous and next images in set.
|
// Preload previous and next images in set.
|
||||||
Lightbox.prototype.preloadNeighboringImages = function() {
|
Lightbox.prototype.preloadNeighboringImages = function() {
|
||||||
if (this.album.length > this.currentImageIndex + 1) {
|
if (this.album.length > this.currentImageIndex + 1 && this.album[this.currentImageIndex + 1].type == 'image') {
|
||||||
var preloadNext = new Image();
|
var preloadNext = new Image();
|
||||||
preloadNext.src = this.album[this.currentImageIndex + 1].link;
|
preloadNext.src = this.album[this.currentImageIndex + 1].link;
|
||||||
}
|
}
|
||||||
if (this.currentImageIndex > 0) {
|
if (this.currentImageIndex > 0 && this.album[this.currentImageIndex - 1].type == 'image') {
|
||||||
var preloadPrev = new Image();
|
var preloadPrev = new Image();
|
||||||
preloadPrev.src = this.album[this.currentImageIndex - 1].link;
|
preloadPrev.src = this.album[this.currentImageIndex - 1].link;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user