feat: started work with directive

This commit is contained in:
2024-07-15 00:05:58 +03:00
parent 45389364ff
commit c9c959ce76
3 changed files with 27 additions and 6 deletions

View File

@@ -0,0 +1,19 @@
import { Directive, ElementRef } from "@angular/core";
@Directive({
selector: "[appLazyLoad]",
standalone: true,
})
export class LazyLoadDirective {
constructor({ nativeElement }: ElementRef) {
const observer = new IntersectionObserver(
(entries) => {
console.log(entries);
},
{
rootMargin: "1000px",
},
);
observer.observe(nativeElement);
}
}

View File

@@ -21,6 +21,7 @@
}
}
</div>
<div appLazyLoad></div>
<div class="flex items-center justify-center space-x-4 my-10">
<button (click)="prevPage()" class="p-3 text-white bg-slate-600 w-[100px] rounded-lg">

View File

@@ -15,6 +15,7 @@ import { Chapter, Page } from "../../services/parsers/rulib/rulib.chapter.dto";
import { IRulibChapter } from "../../services/parsers/rulib/rulib.chapters.dto";
import { SearchService } from "../../services/search.service";
import { ScaleImageComponent } from "../scale-image/scale-image.component";
import { LazyLoadDirective } from "./lazyscroll.directive";
import { CachedPage, CachedPages } from "./reader.dto";
@Component({
@@ -22,7 +23,7 @@ import { CachedPage, CachedPages } from "./reader.dto";
templateUrl: "./reader.component.html",
styleUrls: ["./reader.component.less"],
standalone: true,
imports: [CommonModule, ScaleImageComponent, RouterLink],
imports: [CommonModule, ScaleImageComponent, RouterLink, LazyLoadDirective],
})
export class ReaderComponent implements AfterViewInit, OnDestroy {
//FIXME: Scrolling to top when manhwa
@@ -79,11 +80,11 @@ export class ReaderComponent implements AfterViewInit, OnDestroy {
this.router.navigate(["/"]);
}
});
this.isManhwa$.pipe(takeUntil(this.destroy$)).subscribe((isManhwa) => {
this.isManhwa = isManhwa;
if (isManhwa) this.initManhwaScroll();
else this.noManhwaScroll();
});
// this.isManhwa$.pipe(takeUntil(this.destroy$)).subscribe((isManhwa) => {
// this.isManhwa = isManhwa;
// if (isManhwa) this.initManhwaScroll();
// else this.noManhwaScroll();
// });
}
private handleScrollManhwa(event: Event) {