img-lightbox
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -6,2 +6,6 @@ # Changelog | ||
## 0.1.5 - 2018-12-19 | ||
### Changed | ||
- Fixed on ESC key event bug | ||
## 0.1.4 - 2018-12-18 | ||
@@ -8,0 +12,0 @@ ### Changed |
@@ -6,2 +6,4 @@ /*! | ||
*/ | ||
/*jshint -W014 */ | ||
(function(root, document) { | ||
@@ -21,3 +23,4 @@ "use strict"; | ||
var _length = "length"; | ||
var _removeEventListener = "removeEventListener"; | ||
/* var _removeEventListener = "removeEventListener"; */ | ||
var btnCloseClass = "btn-close"; | ||
@@ -93,4 +96,2 @@ var containerClass = "img-lightbox"; | ||
var handleImgLightboxWindow; | ||
var handleImgLightboxContainerWithBind; | ||
var handleImgLightboxWindowWithBind; | ||
@@ -103,5 +104,2 @@ var hideImgLightbox = function hideImgLightbox() { | ||
: ""; | ||
var btnClose = container | ||
? container[getElementsByClassName](btnCloseClass)[0] || "" | ||
: ""; | ||
@@ -117,2 +115,7 @@ var hideContainer = function hideContainer() { | ||
img[classList].remove(fadeOutDownClass); | ||
img.onload = function() { | ||
container[classList].remove(isLoadedClass); | ||
}; | ||
img.src = dummySrc; | ||
@@ -130,26 +133,2 @@ container[style].display = "none"; | ||
if (container && img) { | ||
container[_removeEventListener]( | ||
"click", | ||
handleImgLightboxContainer | ||
); | ||
container[_removeEventListener]( | ||
"click", | ||
handleImgLightboxContainerWithBind | ||
); | ||
btnClose[_removeEventListener]("click", handleImgLightboxContainer); | ||
btnClose[_removeEventListener]( | ||
"click", | ||
handleImgLightboxContainerWithBind | ||
); | ||
root[_removeEventListener]("keyup", handleImgLightboxWindow); | ||
root[_removeEventListener]( | ||
"keyup", | ||
handleImgLightboxWindowWithBind | ||
); | ||
img[classList].remove(fadeInUpClass); | ||
@@ -182,3 +161,5 @@ img[classList].add(fadeOutDownClass); | ||
handleImgLightboxWindow = function handleImgLightboxWindow(callback, ev) { | ||
if (27 === (ev.which || ev.keyCode)) { | ||
var evt = ev || root.event; | ||
if (27 === (evt.which || evt.keyCode)) { | ||
hideImgLightbox(); | ||
@@ -195,24 +176,20 @@ callCallback(callback, root); | ||
var link = document[getElementsByClassName](_linkClass) || ""; | ||
var container = document[createElement]("div"); | ||
container[classList].add(containerClass); | ||
var html = []; | ||
html.push('<img src="' + dummySrc + '" alt="" />'); | ||
/*! | ||
* @see {@link https://epic-spinners.epicmax.co/} | ||
*/ | ||
/*html.push('<div class="spring-spinner"><div class="spring-spinner-part top"><div class="spring-spinner-rotator"></div></div><div class="spring-spinner-part bottom"><div class="spring-spinner-rotator"></div></div></div>');*/ | ||
html.push( | ||
'<div class="half-circle-spinner"><div class="circle circle-1"></div><div class="circle circle-2"></div></div>' | ||
); | ||
html.push('<a href="javascript:void(0);" class="btn-close"></a>'); | ||
container.innerHTML = html.join(""); | ||
docBody[appendChild](container); | ||
var container = | ||
document[getElementsByClassName](containerClass)[0] || ""; | ||
if (!container) { | ||
container = document[createElement]("div"); | ||
container[classList].add(containerClass); | ||
var containerHTML = []; | ||
containerHTML.push('<img src="' + dummySrc + '" alt="">'); | ||
/*! | ||
* @see {@link https://epic-spinners.epicmax.co/} | ||
*/ | ||
containerHTML.push( | ||
'<div class="half-circle-spinner"><div class="circle circle-1"></div><div class="circle circle-2"></div></div>' | ||
); | ||
containerHTML.push( | ||
'<a href="javascript:void(0);" class="btn-close"></a>' | ||
); | ||
container.innerHTML = containerHTML.join(""); | ||
docBody[appendChild](container); | ||
} | ||
var img = container | ||
@@ -281,14 +258,8 @@ ? container[getElementsByTagName]("img")[0] || "" | ||
if (options.onClosed) { | ||
handleImgLightboxContainerWithBind = handleImgLightboxContainer.bind( | ||
null, | ||
options.onClosed | ||
); | ||
handleImgLightboxWindowWithBind = handleImgLightboxWindow.bind( | ||
null, | ||
options.onClosed | ||
); | ||
container[_addEventListener]( | ||
"click", | ||
handleImgLightboxContainerWithBind | ||
handleImgLightboxContainer.bind( | ||
null, | ||
options.onClosed | ||
) | ||
); | ||
@@ -298,3 +269,6 @@ | ||
"click", | ||
handleImgLightboxContainerWithBind | ||
handleImgLightboxContainer.bind( | ||
null, | ||
options.onClosed | ||
) | ||
); | ||
@@ -304,3 +278,3 @@ | ||
"keyup", | ||
handleImgLightboxWindowWithBind | ||
handleImgLightboxWindow.bind(null, options.onClosed) | ||
); | ||
@@ -307,0 +281,0 @@ } else { |
{ | ||
"name": "img-lightbox", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Responsive no-jQuery pure JS/CSS Lightbox for images, no dependencies, 10kb unminified source code, with demo", | ||
@@ -5,0 +5,0 @@ "keywords": ["lightbox", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
19992
511