Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for custom height and width #130

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions dist/simple-lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ $.fn.simpleLightbox = function( options )
throttleInterval: 0,
doubleTapZoom: 2,
maxZoom: 10,
htmlClass: 'has-lightbox'
htmlClass: 'has-lightbox',
windowHeight: window.innerHeight,
windowWidth: window.innerWidth,
}, options);

// global variables
Expand Down Expand Up @@ -208,8 +210,8 @@ $.fn.simpleLightbox = function( options )
adjustImage = function(dir){
if(!curImg.length) return;
var tmpImage = new Image(),
windowWidth = window.innerWidth * options.widthRatio,
windowHeight = window.innerHeight * options.heightRatio;
windowWidth = options.windowWidth * options.widthRatio,
windowHeight = options.windowHeight * options.heightRatio;
tmpImage.src = curImg.attr( 'src' );
curImg.data('scale',1);
curImg.data('translate-x',0);
Expand Down Expand Up @@ -263,8 +265,8 @@ $.fn.simpleLightbox = function( options )
}

$('.sl-image').css({
'top': ( window.innerHeight - imageHeight ) / 2 + 'px',
'left': ( window.innerWidth - imageWidth - globalScrollbarwidth)/ 2 + 'px',
'top': ( options.windowHeight - imageHeight ) / 2 + 'px',
'left': ( options.windowWidth - imageWidth - globalScrollbarwidth)/ 2 + 'px',
'width': imageWidth + 'px',
'height': imageHeight + 'px'
});
Expand Down Expand Up @@ -677,7 +679,7 @@ $.fn.simpleLightbox = function( options )
handleScrollbar = function(type){
var scrollbarWidth = 0;
if(type == 'hide'){
var fullWindowWidth = window.innerWidth;
var fullWindowWidth = options.windowWidth;
if (!fullWindowWidth) {
var documentElementRect = document.documentElement.getBoundingClientRect();
fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "simplelightbox",
"version": "1.16.3",
"version": "1.16.4",
"description": "Touch-friendly image lightbox for mobile and desktop with jQuery",
"main": "dist/simple-lightbox.js",
"style": "dist/simplelightbox.scss",
"repository": {
"type": "git",
"url": "https://github.com/andreknieriem/simplelightbox.git"
"url": "https://github.com/caagsoftware/simplelightbox.git"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this.

},
"dependencies": {
"jquery": ">=1.7.0"
Expand Down