Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simplelightbox

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simplelightbox - npm Package Compare versions

Comparing version 1.4.6 to 1.5.0

2

bower.json
{
"name": "simplelightbox",
"version": "1.4.6",
"version": "1.5.0",
"homepage": "http://andreknieriem.de/simple-lightbox",

@@ -5,0 +5,0 @@ "authors": [

@@ -15,24 +15,25 @@

var options = $.extend({
overlay: true,
spinner: true,
nav: true,
navText: ['←','→'],
captions: true,
captionSelector:'img',
captionType: 'attr',
captionsData: 'title',
close: true,
closeText: '×',
showCounter: true,
fileExt: 'png|jpg|jpeg|gif',
animationSpeed: 250,
preloading: true,
enableKeyboard: true,
loop: true,
docClose: true,
swipeTolerance: 50,
className: 'simple-lightbox',
widthRatio: 0.8,
heightRatio: 0.9
overlay: true,
spinner: true,
nav: true,
navText: ['‹','›'],
captions: true,
captionSelector: 'img',
captionType: 'attr',
captionsData: 'title',
close: true,
closeText: '×',
showCounter: true,
fileExt: 'png|jpg|jpeg|gif',
animationSpeed: 250,
preloading: true,
enableKeyboard: true,
loop: true,
docClose: true,
swipeTolerance: 50,
className: 'simple-lightbox',
widthRatio: 0.8,
heightRatio: 0.9,
disableRightClick: false,
disableScroll: true
}, options );

@@ -105,2 +106,3 @@

elem.trigger($.Event('show.simplelightbox'));
if(options.disableScroll) handleScrollbar('hide');
wrapper.appendTo('body');

@@ -122,5 +124,3 @@ if(options.overlay) overlay.appendTo($('body'));

adjustImage();
if(options.preloading){
preload();
}
if(options.preloading) preload();
setTimeout( function(){ elem.trigger($.Event('shown.simplelightbox'));} ,options.animationSpeed);

@@ -232,3 +232,4 @@ },

$('.sl-image img, .sl-overlay, .sl-close, .sl-navigation, .sl-image .sl-caption, .sl-counter').fadeOut('fast', function(){
$('.sl-wrapper, .sl-overlay').remove();
if(options.disableScroll) handleScrollbar('show');
$('.sl-wrapper, .sl-overlay').remove();
if(!triggered) elem.trigger($.Event('closed.simplelightbox'));

@@ -239,2 +240,26 @@ triggered = true;

opened = false;
},
handleScrollbar = function(type){
if(type == 'hide'){
var fullWindowWidth = window.innerWidth;
if (!fullWindowWidth) {
var documentElementRect = document.documentElement.getBoundingClientRect()
fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left)
}
if(document.body.clientWidth < fullWindowWidth){
var scrollDiv = document.createElement('div'),
padding = parseInt($('body').css('padding-right'),10);
scrollDiv.className = 'sl-scrollbar-measure';
$('body').append(scrollDiv);
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
$(document.body)[0].removeChild(scrollDiv);
$('body').data('padding',padding);
console.log(padding, scrollbarWidth);
if(scrollbarWidth > 0){
$('body').css({'padding-right':padding+scrollbarWidth, 'overflow':'hidden'});
}
}
} else {
$('body').css({'padding-right':$('body').data('padding'), 'overflow':'auto'});
}
}

@@ -266,4 +291,3 @@

if(opened){
if((options.docClose && $(e.target).closest('.sl-image').length == 0 && $(e.target).closest('.sl-navigation').length == 0)
){
if((options.docClose && $(e.target).closest('.sl-image').length == 0 && $(e.target).closest('.sl-navigation').length == 0)){
close();

@@ -274,2 +298,9 @@ }

// disable rightclick
if(options.disableRightClick){
$(document).on('contextmenu', '.sl-image img', function(e){
return false;
});
}
// nav-buttons

@@ -276,0 +307,0 @@ $(document).on('click', '.sl-navigation button', function(e){

/*
By Andre Rinas, www.andreknieriem.de
By André Rinas, www.andreknieriem.de
Available for use under the MIT License
*/
!function(e,t,n){"use strict";e.fn.simpleLightbox=function(a){var a=e.extend({overlay:!0,spinner:!0,nav:!0,navText:["&larr;","&rarr;"],captions:!0,captionSelector:"img",captionType:"attr",captionsData:"title",close:!0,closeText:"×",showCounter:!0,fileExt:"png|jpg|jpeg|gif",animationSpeed:250,preloading:!0,enableKeyboard:!0,loop:!0,docClose:!0,swipeTolerance:50,className:"simple-lightbox",widthRatio:.8,heightRatio:.9},a),i=(t.navigator.pointerEnabled||t.navigator.msPointerEnabled,0),o=e(),s=function(){var e=n.body||n.documentElement,e=e.style;return""==e.WebkitTransition?"-webkit-":""==e.MozTransition?"-moz-":""==e.OTransition?"-o-":""==e.transition?"":!1},l=!1,r=this.selector,s=s(),p=s!==!1?!0:!1,c="simplelb",d=e("<div>").addClass("sl-overlay"),f=e("<button>").addClass("sl-close").html(a.closeText),u=e("<div>").addClass("sl-spinner").html("<div></div>"),g=e("<div>").addClass("sl-navigation").html('<button class="sl-prev">'+a.navText[0]+'</button><button class="sl-next">'+a.navText[1]+"</button>"),h=e("<div>").addClass("sl-counter").html('<span class="sl-current"></span>/<span class="sl-total"></span>'),m=!1,v=0,x=e(),w=e("<div>").addClass("sl-caption"),b=e("<div>").addClass("sl-wrapper").addClass(a.className).html('<div class="sl-image"></div>'),y=function(t){return a.fileExt?"a"==e(t).prop("tagName").toLowerCase()&&new RegExp(".("+a.fileExt+")$","i").test(e(t).attr("href")):!0},T=function(){x=e(".sl-image"),a.close&&f.appendTo(b),a.showCounter&&e(r).length>1&&(h.appendTo(b),h.find(".sl-total").text(e(r).length)),a.nav&&g.appendTo(b),a.spinner&&u.appendTo(b)},C=function(t){t.trigger(e.Event("show.simplelightbox")),b.appendTo("body"),a.overlay&&d.appendTo(e("body")),m=!0,v=e(r).index(t),o=e("<img/>").hide().attr("src",t.attr("href")),e(".sl-image").html(""),o.appendTo(e(".sl-image")),d.fadeIn("fast"),e(".sl-close").fadeIn("fast"),u.show(),g.fadeIn("fast"),e(".sl-wrapper .sl-counter .sl-current").text(v+1),h.fadeIn("fast"),E(),a.preloading&&I(),setTimeout(function(){t.trigger(e.Event("shown.simplelightbox"))},a.animationSpeed)},E=function(n){if(o.length){var i=new Image,s=e(t).width()*a.widthRatio,c=e(t).height()*a.heightRatio;i.src=o.attr("src"),i.onload=function(){var d=i.width,f=i.height;if(d>s||f>c){var g=d/f>s/c?d/s:f/c;d/=g,f/=g}e(".sl-image").css({top:(e(t).height()-f)/2+"px",left:(e(t).width()-d)/2+"px"}),u.hide(),o.css({width:d+"px",height:f+"px"}).fadeIn("fast"),l=!0;var h="self"==a.captionSelector?e(r).eq(v):e(r).eq(v).find(a.captionSelector);if("data"==a.captionType)var x=h.data(a.captionsData);else if("text"==a.captionType)var x=h.html();else var x=h.prop(a.captionsData);if(1==n||-1==n){var w={opacity:1};p?(k(0,100*n+"px"),setTimeout(function(){k(a.animationSpeed/1e3,"0px"),50})):w.left=parseInt(e(".sl-image").css("left"))+100*n+"px",e(".sl-image").animate(w,a.animationSpeed,function(){m=!1,S(x)})}else m=!1,S(x)}}},S=function(t){""!=t&&"undefined"!=typeof t&&a.captions&&w.html(t).hide().appendTo(e(".sl-image")).fadeIn("fast")},k=function(t,n){var a={};a[s+"transform"]="translateX("+n+")",a[s+"transition"]=s+"transform "+t+"s linear",e(".sl-image").css(a)},I=function(){var t=0>v+1?e(r).length-1:v+1>=e(r).length-1?0:v+1,n=0>v-1?e(r).length-1:v-1>=e(r).length-1?0:v-1;e("<img />").attr("src",e(r).eq(t).attr("href")).load(),e("<img />").attr("src",e(r).eq(n).attr("href")).load()},D=function(t){u.show();var n=v+t;if(!(m||(0>n||n>=e(r).length)&&0==a.loop)){m=!0,v=0>n?e(r).length-1:n>e(r).length-1?0:n,e(".sl-wrapper .sl-counter .sl-current").text(v+1);var s={opacity:0};p?k(a.animationSpeed/1e3,-100*t-i+"px"):s.left=parseInt(e(".sl-image").css("left"))+-100*t+"px",e(".sl-image").animate(s,a.animationSpeed,function(){setTimeout(function(){var n=e(r).eq(v);o.attr("src",n.attr("href")),e(".sl-caption").remove(),E(t),a.preloading&&I()},100)})}},M=function(){if(!m){var t=e(r).eq(v),n=!1;t.trigger(e.Event("close.simplelightbox")),e(".sl-image img, .sl-overlay, .sl-close, .sl-navigation, .sl-image .sl-caption, .sl-counter").fadeOut("fast",function(){e(".sl-wrapper, .sl-overlay").remove(),n||t.trigger(e.Event("closed.simplelightbox")),n=!0}),o=e(),l=!1}};T(),e(t).on("resize",E),e(n).on("click."+c,this.selector,function(t){if(y(this)){if(t.preventDefault(),m)return!1;C(e(this))}}),e(n).on("click",".sl-close",function(e){e.preventDefault(),l&&M()}),e(n).click(function(t){l&&a.docClose&&0==e(t.target).closest(".sl-image").length&&0==e(t.target).closest(".sl-navigation").length&&M()}),e(n).on("click",".sl-navigation button",function(t){t.preventDefault(),i=0,D(e(this).hasClass("sl-next")?1:-1)}),a.enableKeyboard&&e(n).on("keyup."+c,function(e){if(e.preventDefault(),i=0,l){var t=e.keyCode;27==t&&M(),(37==t||39==e.keyCode)&&D(39==e.keyCode?1:-1)}});var q=0,P=0,R=!1,X=0;return e(n).on("touchstart mousedown pointerdown MSPointerDown",".sl-image",function(e){return R?!0:(p&&(X=parseInt(x.css("left"))),R=!0,q=e.originalEvent.pageX||e.originalEvent.touches[0].pageX,!1)}).on("touchmove mousemove pointermove MSPointerMove",function(e){return R?(e.preventDefault(),P=e.originalEvent.pageX||e.originalEvent.touches[0].pageX,i=q-P,void(p?k(0,-i+"px"):x.css("left",X-i+"px"))):!0}).on("touchend mouseup touchcancel pointerup pointercancel MSPointerUp MSPointerCancel",function(){R&&(R=!1,Math.abs(i)>a.swipeTolerance?D(i>0?1:-1):p?k(a.animationSpeed/1e3,"0px"):x.animate({left:X+"px"},a.animationSpeed/2))}),this.open=function(e){C(e)},this.next=function(){D(1)},this.prev=function(){D(-1)},this.close=function(){M()},this.destroy=function(){e(n).unbind("click."+c).unbind("keyup."+c),M(),e(".sl-overlay, .sl-wrapper").remove()},this}}(jQuery,window,document);
!function(e,t,n){"use strict";e.fn.simpleLightbox=function(i){var i=e.extend({overlay:!0,spinner:!0,nav:!0,navText:["&lsaquo;","&rsaquo;"],captions:!0,captionSelector:"img",captionType:"attr",captionsData:"title",close:!0,closeText:"×",showCounter:!0,fileExt:"png|jpg|jpeg|gif",animationSpeed:250,preloading:!0,enableKeyboard:!0,loop:!0,docClose:!0,swipeTolerance:50,className:"simple-lightbox",widthRatio:.8,heightRatio:.9,disableRightClick:!1,disableScroll:!0},i),a=(t.navigator.pointerEnabled||t.navigator.msPointerEnabled,0),o=e(),s=function(){var e=n.body||n.documentElement,e=e.style;return""==e.WebkitTransition?"-webkit-":""==e.MozTransition?"-moz-":""==e.OTransition?"-o-":""==e.transition?"":!1},l=!1,r=this.selector,s=s(),c=s!==!1?!0:!1,d="simplelb",p=e("<div>").addClass("sl-overlay"),f=e("<button>").addClass("sl-close").html(i.closeText),g=e("<div>").addClass("sl-spinner").html("<div></div>"),h=e("<div>").addClass("sl-navigation").html('<button class="sl-prev">'+i.navText[0]+'</button><button class="sl-next">'+i.navText[1]+"</button>"),u=e("<div>").addClass("sl-counter").html('<span class="sl-current"></span>/<span class="sl-total"></span>'),m=!1,v=0,b=e(),x=e("<div>").addClass("sl-caption"),y=e("<div>").addClass("sl-wrapper").addClass(i.className).html('<div class="sl-image"></div>'),w=function(t){return i.fileExt?"a"==e(t).prop("tagName").toLowerCase()&&new RegExp(".("+i.fileExt+")$","i").test(e(t).attr("href")):!0},T=function(){b=e(".sl-image"),i.close&&f.appendTo(y),i.showCounter&&e(r).length>1&&(u.appendTo(y),u.find(".sl-total").text(e(r).length)),i.nav&&h.appendTo(y),i.spinner&&g.appendTo(y)},C=function(t){t.trigger(e.Event("show.simplelightbox")),i.disableScroll&&M("hide"),y.appendTo("body"),i.overlay&&p.appendTo(e("body")),m=!0,v=e(r).index(t),o=e("<img/>").hide().attr("src",t.attr("href")),e(".sl-image").html(""),o.appendTo(e(".sl-image")),p.fadeIn("fast"),e(".sl-close").fadeIn("fast"),g.show(),h.fadeIn("fast"),e(".sl-wrapper .sl-counter .sl-current").text(v+1),u.fadeIn("fast"),S(),i.preloading&&I(),setTimeout(function(){t.trigger(e.Event("shown.simplelightbox"))},i.animationSpeed)},S=function(n){if(o.length){var a=new Image,s=e(t).width()*i.widthRatio,d=e(t).height()*i.heightRatio;a.src=o.attr("src"),a.onload=function(){var p=a.width,f=a.height;if(p>s||f>d){var h=p/f>s/d?p/s:f/d;p/=h,f/=h}e(".sl-image").css({top:(e(t).height()-f)/2+"px",left:(e(t).width()-p)/2+"px"}),g.hide(),o.css({width:p+"px",height:f+"px"}).fadeIn("fast"),l=!0;var u="self"==i.captionSelector?e(r).eq(v):e(r).eq(v).find(i.captionSelector);if("data"==i.captionType)var b=u.data(i.captionsData);else if("text"==i.captionType)var b=u.html();else var b=u.prop(i.captionsData);if(1==n||-1==n){var x={opacity:1};c?(k(0,100*n+"px"),setTimeout(function(){k(i.animationSpeed/1e3,"0px"),50})):x.left=parseInt(e(".sl-image").css("left"))+100*n+"px",e(".sl-image").animate(x,i.animationSpeed,function(){m=!1,E(b)})}else m=!1,E(b)}}},E=function(t){""!=t&&"undefined"!=typeof t&&i.captions&&x.html(t).hide().appendTo(e(".sl-image")).fadeIn("fast")},k=function(t,n){var i={};i[s+"transform"]="translateX("+n+")",i[s+"transition"]=s+"transform "+t+"s linear",e(".sl-image").css(i)},I=function(){var t=0>v+1?e(r).length-1:v+1>=e(r).length-1?0:v+1,n=0>v-1?e(r).length-1:v-1>=e(r).length-1?0:v-1;e("<img />").attr("src",e(r).eq(t).attr("href")).load(),e("<img />").attr("src",e(r).eq(n).attr("href")).load()},D=function(t){g.show();var n=v+t;if(!(m||(0>n||n>=e(r).length)&&0==i.loop)){m=!0,v=0>n?e(r).length-1:n>e(r).length-1?0:n,e(".sl-wrapper .sl-counter .sl-current").text(v+1);var s={opacity:0};c?k(i.animationSpeed/1e3,-100*t-a+"px"):s.left=parseInt(e(".sl-image").css("left"))+-100*t+"px",e(".sl-image").animate(s,i.animationSpeed,function(){setTimeout(function(){var n=e(r).eq(v);o.attr("src",n.attr("href")),e(".sl-caption").remove(),S(t),i.preloading&&I()},100)})}},q=function(){if(!m){var t=e(r).eq(v),n=!1;t.trigger(e.Event("close.simplelightbox")),e(".sl-image img, .sl-overlay, .sl-close, .sl-navigation, .sl-image .sl-caption, .sl-counter").fadeOut("fast",function(){i.disableScroll&&M("show"),e(".sl-wrapper, .sl-overlay").remove(),n||t.trigger(e.Event("closed.simplelightbox")),n=!0}),o=e(),l=!1}},M=function(i){if("hide"==i){var a=t.innerWidth;if(!a){var o=n.documentElement.getBoundingClientRect();a=o.right-Math.abs(o.left)}if(n.body.clientWidth<a){var s=n.createElement("div"),l=parseInt(e("body").css("padding-right"),10);s.className="sl-scrollbar-measure",e("body").append(s);var r=s.offsetWidth-s.clientWidth;e(n.body)[0].removeChild(s),e("body").data("padding",l),console.log(l,r),r>0&&e("body").css({"padding-right":l+r,overflow:"hidden"})}}else e("body").css({"padding-right":e("body").data("padding"),overflow:"auto"})};T(),e(t).on("resize",S),e(n).on("click."+d,this.selector,function(t){if(w(this)){if(t.preventDefault(),m)return!1;C(e(this))}}),e(n).on("click",".sl-close",function(e){e.preventDefault(),l&&q()}),e(n).click(function(t){l&&i.docClose&&0==e(t.target).closest(".sl-image").length&&0==e(t.target).closest(".sl-navigation").length&&q()}),i.disableRightClick&&e(n).on("contextmenu",".sl-image img",function(){return!1}),e(n).on("click",".sl-navigation button",function(t){t.preventDefault(),a=0,D(e(this).hasClass("sl-next")?1:-1)}),i.enableKeyboard&&e(n).on("keyup."+d,function(e){if(e.preventDefault(),a=0,l){var t=e.keyCode;27==t&&q(),(37==t||39==e.keyCode)&&D(39==e.keyCode?1:-1)}});var R=0,P=0,W=!1,X=0;return e(n).on("touchstart mousedown pointerdown MSPointerDown",".sl-image",function(e){return W?!0:(c&&(X=parseInt(b.css("left"))),W=!0,R=e.originalEvent.pageX||e.originalEvent.touches[0].pageX,!1)}).on("touchmove mousemove pointermove MSPointerMove",function(e){return W?(e.preventDefault(),P=e.originalEvent.pageX||e.originalEvent.touches[0].pageX,a=R-P,void(c?k(0,-a+"px"):b.css("left",X-a+"px"))):!0}).on("touchend mouseup touchcancel pointerup pointercancel MSPointerUp MSPointerCancel",function(){W&&(W=!1,Math.abs(a)>i.swipeTolerance?D(a>0?1:-1):c?k(i.animationSpeed/1e3,"0px"):b.animate({left:X+"px"},i.animationSpeed/2))}),this.open=function(e){C(e)},this.next=function(){D(1)},this.prev=function(){D(-1)},this.close=function(){q()},this.destroy=function(){e(n).unbind("click."+d).unbind("keyup."+d),q(),e(".sl-overlay, .sl-wrapper").remove()},this}}(jQuery,window,document);
{
"name": "simplelightbox",
"version": "1.4.6",
"version": "1.5.0",
"description": "Touch-friendly image lightbox for mobile and desktop with jQuery",

@@ -5,0 +5,0 @@ "main": "dist/simple-lightbox.js",

@@ -43,2 +43,4 @@ # simplelightbox

| heightRatio: | 0.9 | float | Ratio of image height to screen height |
| disableRightClick | false | bool | disable rightclick on image or not |
| disableScroll | true | bool | stop scrolling page if lightbox is openend |

@@ -76,2 +78,3 @@ ###Events

### Changelog
**1.5.0 - Added options for disabling rightclick and scrolling, changed default prev- and next-button text**
**1.4.6 - Option for fileExt can now be false to enable pictures like example.com/pic/200/100**

@@ -78,0 +81,0 @@ **1.4.5 - Bugfix lightbox opening does not work on mobile devices**

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc