8000 Add zoomable option by ToX82 · Pull Request #553 · lokesh/lightbox2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add zoomable option #553

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

Open
wants to merge 1 commit 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>Lightbox Example</title>
<link rel="stylesheet" href="../dist/css/lightbox.min.css">
<link rel="stylesheet" href="../src/css/lightbox.css">
</head>
<body>

Expand Down Expand Up @@ -31,7 +31,13 @@ <h3>A Four Image Set</h3>
</p>
</section>

<script src="../dist/js/lightbox-plus-jquery.min.js"></script>
<script src="//code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="../src/js/lightbox.js"></script>
<script>
lightbox.option({
'zoomable': true
})
</script>

</body>
</html>
27 changes: 26 additions & 1 deletion src/css/lightbox.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Preload images */
body:after {
content: url(../images/close.png) url(../images/loading.gif) url(../images/prev.png) url(../images/next.png);
content: url(../images/close.png) url(../images/loading.gif) url(../images/prev.png) url(../images/next.png) url(../images/zoom.png);
display: none;
}

Expand Down Expand Up @@ -211,3 +211,28 @@ body.lb-disable-scrolling {
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
opacity: 1;
}

.lb-zoom {
display: none;
position: absolute;
right: 10px;
top: 10px;
width: 30px;
height: 30px;
background: url(../images/zoom.png) top right no-repeat;
text-align: right;
outline: none;
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80);
opacity: 0.8;
-webkit-transition: opacity 0.2s;
-moz-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
transition: opacity 0.2s;
z-index: 10001;
}

.lb-zoom:hover {
cursor: pointer;
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
opacity: 1;
}
Binary file added src/images/zoom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion src/js/lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
showImageNumberLabel: true,
wrapAround: false,
disableScrolling: false,
zoomable: false,
/*
Sanitize Title
If the caption data is trusted, for example you are hardcoding it in, then leave this to false.
Expand Down Expand Up @@ -93,7 +94,7 @@
// Attach event handlers to the new DOM elements. click click click
Lightbox.prototype.build = function() {
var self = this;
$('<div id="lightboxOverlay" class="lightboxOverlay"></div><div id="lightbox" class="lightbox"><div class="lb-outerContainer"><div class="lb-container"><img class="lb-image" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" /><div class="lb-nav"><a class="lb-prev" href="" ></a><a class="lb-next" href="" ></a></div><div class="lb-loader"><a class="lb-cancel"></a></div></div></div><div class="lb-dataContainer"><div class="lb-data"><div class="lb-details"><span class="lb-caption"></span><span class="lb-number"></span></div><div class="lb-closeContainer"><a class="lb-close"></a></div></div></div></div>').appendTo($('body'));
$('<div id="lightboxOverlay" class="lightboxOverlay"></div><div id="lightbox" class="lightbox"><div class="lb-outerContainer"><div class="lb-container"><img class="lb-image" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" /><a class="lb-zoom"></a><div class="lb-nav"><a class="lb-prev" href="" ></a><a class="lb-next" href="" ></a></div><div class="lb-loader"><a class="lb-cancel"></a></div></div></div><div class="lb-dataContainer"><div class="lb-data"><div class="lb-details"><span class="lb-caption"></span><span class="lb-number"></span></div><div class="lb-closeContainer"><a class="lb-close"></a></div></div></div></div>').appendTo($('body'));

// Cache jQuery objects
this.$lightbox = $('#lightbox');
Expand Down Expand Up @@ -156,6 +157,11 @@
return false;
});

this.$lightbox.find('.lb-zoom').on('click', function() {
window.open(self.$image[0].src, '_blank');
return false;
});

/*
Show context menu for image on right-click

Expand Down Expand Up @@ -252,6 +258,11 @@
$('body').addClass('lb-disable-scrolling');
}

// Show zoom lens when needed
if (this.options.zoomable) {
$('.lb-zoom').show();
}

this.changeImage(imageNumber);
};

Expand Down
0