Skip to content
This repository has been archived by the owner on May 22, 2020. It is now read-only.

Added option #311

Open
wants to merge 4 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified dist/ekko-lightbox.css
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions dist/ekko-lightbox.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,115 changes: 571 additions & 544 deletions dist/ekko-lightbox.js
100644 → 100755

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ekko-lightbox.js.map
100644 → 100755

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ekko-lightbox.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ekko-lightbox.min.js.map
100644 → 100755

Large diffs are not rendered by default.

36 changes: 25 additions & 11 deletions ekko-lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Lightbox = (($) => {
maxWidth: 9999,
maxHeight: 9999,
showArrows: true, //display the left / right arrows or not
swipeGesture: true, //if true, enable swipe events
wrapping: true, //if true, gallery loops infinitely
type: null, //force the lightbox into image / youtube mode. if null, or not image|youtube|vimeo; detect it
alwaysShowClose: false, //always show the close button, even if there is no title
Expand All @@ -26,7 +27,8 @@ const Lightbox = (($) => {
onHide() {},
onHidden() {},
onNavigate() {},
onContentLoaded() {}
onContentLoaded() {},
updateGallery() {}
}

class Lightbox {
Expand Down Expand Up @@ -146,15 +148,18 @@ const Lightbox = (($) => {
$(window).on('resize.ekkoLightbox', () => {
this._resize(this._wantedWidth, this._wantedHeight)
})
this._$lightboxContainer
.on('touchstart', () => {
this._touchstartX = event.changedTouches[0].screenX;

})
.on('touchend', () => {
this._touchendX = event.changedTouches[0].screenX;
this._swipeGesure();
})

if(this._config.swipeGesture) {
this._$lightboxContainer
.on('touchstart', () => {
this._touchstartX = event.changedTouches[0].screenX;

})
.on('touchend', () => {
this._touchendX = event.changedTouches[0].screenX;
this._swipeGesture();
})
}
}

element() {
Expand Down Expand Up @@ -239,6 +244,15 @@ const Lightbox = (($) => {
return this._$modal.modal('hide');
}

// update lightbox gallery items
updateGallery() {
this._galleryName = this._$element.data('gallery')
if (this._galleryName) {
this._$galleryItems = $(document.body).find(`*[data-gallery="${this._galleryName}"]`)
this.updateNavigation()
}
}

// helper private methods
_navigationalBinder(event) {
event = event || window.event;
Expand Down Expand Up @@ -594,7 +608,7 @@ const Lightbox = (($) => {
return img;
}

_swipeGesure() {
_swipeGesture() {
if (this._touchendX < this._touchstartX) {
return this.navigateRight();
}
Expand Down
Loading