Slight cleanup
This commit is contained in:
parent
3eb7f43908
commit
1dbb53e628
3 changed files with 9 additions and 8 deletions
|
|
@ -242,7 +242,7 @@ export class InfiniteScrollerComponent implements OnInit, OnChanges, OnDestroy,
|
||||||
|
|
||||||
// We need the injector as toSignal is only allowed in injection context
|
// We need the injector as toSignal is only allowed in injection context
|
||||||
// https://angular.dev/guide/signals#injection-context
|
// https://angular.dev/guide/signals#injection-context
|
||||||
this.readerSettings = toSignal(this.readerSettings$, {injector: this.injector}) as Signal<ReaderSetting>;
|
this.readerSettings = toSignal(this.readerSettings$, {injector: this.injector, requireSync: true});
|
||||||
|
|
||||||
// Automatically updates when the breakpoint changes, or when reader settings changes
|
// Automatically updates when the breakpoint changes, or when reader settings changes
|
||||||
this.widthOverride = computed(() => {
|
this.widthOverride = computed(() => {
|
||||||
|
|
@ -255,7 +255,7 @@ export class InfiniteScrollerComponent implements OnInit, OnChanges, OnDestroy,
|
||||||
return (parseInt(value) <= 0) ? '' : value + '%';
|
return (parseInt(value) <= 0) ? '' : value + '%';
|
||||||
});
|
});
|
||||||
|
|
||||||
//perform jump so the page stays in view (NOT WORKING)
|
//perform jump so the page stays in view
|
||||||
effect(() => {
|
effect(() => {
|
||||||
const width = this.widthOverride(); // needs to be at the top for effect to work
|
const width = this.widthOverride(); // needs to be at the top for effect to work
|
||||||
this.currentPageElem = this.document.querySelector('img#page-' + this.pageNum);
|
this.currentPageElem = this.document.querySelector('img#page-' + this.pageNum);
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ export class SingleRendererComponent implements OnInit, ImageRenderer {
|
||||||
takeUntilDestroyed(this.destroyRef)
|
takeUntilDestroyed(this.destroyRef)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.readerSettings = toSignal(this.readerSettings$, {injector: this.injector}) as Signal<ReaderSetting>;
|
this.readerSettings = toSignal(this.readerSettings$, {injector: this.injector, requireSync: true});
|
||||||
this.widthOverride = computed(() => {
|
this.widthOverride = computed(() => {
|
||||||
const breakpoint = this.utilityService.activeUserBreakpoint();
|
const breakpoint = this.utilityService.activeUserBreakpoint();
|
||||||
const value = this.readerSettings().widthSlider;
|
const value = this.readerSettings().widthSlider;
|
||||||
|
|
|
||||||
|
|
@ -175,23 +175,24 @@ export class UtilityService {
|
||||||
const style = getComputedStyle(this.document.body)
|
const style = getComputedStyle(this.document.body)
|
||||||
const mobileBreakPoint = this.parseOrDefault<number>(style.getPropertyValue('--mobile-breakpoint'), Breakpoint.Mobile);
|
const mobileBreakPoint = this.parseOrDefault<number>(style.getPropertyValue('--mobile-breakpoint'), Breakpoint.Mobile);
|
||||||
const tabletBreakPoint = this.parseOrDefault<number>(style.getPropertyValue('--tablet-breakpoint'), Breakpoint.Tablet);
|
const tabletBreakPoint = this.parseOrDefault<number>(style.getPropertyValue('--tablet-breakpoint'), Breakpoint.Tablet);
|
||||||
const desktopBreakPoint = this.parseOrDefault<number>(style.getPropertyValue('--desktop-breakpoint'), Breakpoint.Desktop);
|
//const desktopBreakPoint = this.parseOrDefault<number>(style.getPropertyValue('--desktop-breakpoint'), Breakpoint.Desktop);
|
||||||
|
|
||||||
if (window.innerWidth <= mobileBreakPoint) {
|
if (window.innerWidth <= mobileBreakPoint) {
|
||||||
return UserBreakpoint.Mobile;
|
return UserBreakpoint.Mobile;
|
||||||
} else if (window.innerWidth >= mobileBreakPoint && window.innerWidth <= tabletBreakPoint) {
|
} else if (window.innerWidth <= tabletBreakPoint) {
|
||||||
return UserBreakpoint.Tablet;
|
return UserBreakpoint.Tablet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback to desktop
|
||||||
return UserBreakpoint.Desktop;
|
return UserBreakpoint.Desktop;
|
||||||
}
|
}
|
||||||
|
|
||||||
private parseOrDefault<T>(s: string, def: T): T {
|
private parseOrDefault<T>(s: string, def: T): T {
|
||||||
try {
|
const ret = parseInt(s, 10);
|
||||||
return parseInt(s, 10) as T;
|
if (isNaN(ret)) {
|
||||||
} catch (e) {
|
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
return ret as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
isInViewport(element: Element, additionalTopOffset: number = 0) {
|
isInViewport(element: Element, additionalTopOffset: number = 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue