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

Implement Infinite Scrolling for Slider-Lightbox #205

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Binary file added ng-image-slider-7.0.1.tgz
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ export class SliderLightboxComponent implements OnInit, AfterViewInit, OnDestroy
if (index !== undefined && index > -1 && index < this.images.length) {
this.currentImageIndex = index;
}
this.nextPrevDisable();
// this.nextPrevDisable();
}
@Input()
set show(visiableFlag: boolean) {
@@ -130,7 +130,7 @@ export class SliderLightboxComponent implements OnInit, AfterViewInit, OnDestroy
if (typeof (this.currentImageIndex) === 'number' && this.currentImageIndex !== undefined) {
this.marginLeft = -1 * this.popupWidth * this.currentImageIndex;
this.getImageData();
this.nextPrevDisable();
//this.nextPrevDisable();
setTimeout(() => {
this.showLoading = false;
}, 500);
@@ -143,45 +143,54 @@ export class SliderLightboxComponent implements OnInit, AfterViewInit, OnDestroy
}

prevImageLightbox() {
// If the current image index is the first image, then set the current image index to the last image index
if(this.infinite && this.currentImageIndex === 0) {
this.currentImageIndex = this.images.length;
}
this.effectStyle = `all ${this.speed}s ease-in-out`;
if (this.currentImageIndex > 0 && !this.lightboxPrevDisable) {
if (this.currentImageIndex > 0 ) {//&& !this.lightboxPrevDisable
this.currentImageIndex--;
this.prevImage.emit(LIGHTBOX_PREV_ARROW_CLICK_MESSAGE);
this.marginLeft = -1 * this.popupWidth * this.currentImageIndex;
this.getImageData();
this.nextPrevDisable();
// this.nextPrevDisable();
}
}

nextImageLightbox() {
// If the current image is the last image, then reset the current image index to -1
if(this.infinite && this.currentImageIndex === this.images.length - 1) {
this.currentImageIndex = -1;
}

this.effectStyle = `all ${this.speed}s ease-in-out`;
if (this.currentImageIndex < this.images.length - 1 && !this.lightboxNextDisable) {
if (this.currentImageIndex < this.images.length - 1 ) {//&& !this.lightboxNextDisable
this.currentImageIndex++;
this.nextImage.emit(LIGHTBOX_NEXT_ARROW_CLICK_MESSAGE);
this.marginLeft = -1 * this.popupWidth * this.currentImageIndex;
this.getImageData();
this.nextPrevDisable();
//this.nextPrevDisable();
}
}

nextPrevDisable() {
this.lightboxNextDisable = true;
this.lightboxPrevDisable = true;
setTimeout(() => {
this.applyButtonDisableCondition();
}, this.speed * 1000);
}

applyButtonDisableCondition() {
this.lightboxNextDisable = false;
this.lightboxPrevDisable = false;
if (!this.infinite && this.currentImageIndex >= this.images.length - 1) {
this.lightboxNextDisable = true;
}
if (!this.infinite && this.currentImageIndex <= 0) {
this.lightboxPrevDisable = true;
}
}
// nextPrevDisable() {
// this.lightboxNextDisable = true;
// this.lightboxPrevDisable = true;
// setTimeout(() => {
// this.applyButtonDisableCondition();
// }, this.speed * 1000);
// }

// applyButtonDisableCondition() {
// this.lightboxNextDisable = false;
// this.lightboxPrevDisable = false;
// if (!this.infinite && this.currentImageIndex >= this.images.length - 1) {
// this.lightboxNextDisable = true;
// }
// if (!this.infinite && this.currentImageIndex <= 0) {
// this.lightboxPrevDisable = true;
// }
// }

getImageData() {
if (this.images