diff --git a/src/lightbox.component.ts b/src/lightbox.component.ts index 4eebc98..004dc78 100644 --- a/src/lightbox.component.ts +++ b/src/lightbox.component.ts @@ -255,8 +255,8 @@ export class LightboxComponent implements AfterViewInit, OnDestroy { this._cssValue.imageBorderWidthLeft + this._cssValue.imageBorderWidthRight; const newHeight = imageHeight + this._cssValue.containerTopPadding + this._cssValue.containerBottomPadding + this._cssValue.imageBorderWidthTop + this._cssValue.imageBorderWidthBottom; - - if (oldWidth !== newWidth || oldHeight !== newHeight) { + // make sure that distances are large enough for transitionend event to be fired, at least 5px. + if (Math.abs(oldWidth - newWidth) + Math.abs(oldHeight - newHeight) > 5) { this._rendererRef.setElementStyle(this._outerContainerElem.nativeElement, 'width', `${newWidth}px`); this._rendererRef.setElementStyle(this._outerContainerElem.nativeElement, 'height', `${newHeight}px`);