Tweak the preload stuff

This commit is contained in:
shamoon 2024-11-19 16:37:18 -08:00
parent d4c05ad46e
commit 432d81845e
3 changed files with 6 additions and 7 deletions

View File

@ -1,6 +1,6 @@
<a [href]="previewUrl" target="_blank" class="{{btn_classes}}"
[ngbPopover]="previewContent" [popoverTitle]="document.title | documentTitle"
autoClose="true" popoverClass="shadow popover-preview" (mouseenter)="mouseEnterPreview()" (mouseleave)="mouseLeavePreview()" #popover="ngbPopover">
autoClose="true" [popoverClass]="popoverClass" (mouseenter)="mouseEnterPreview()" (mouseleave)="mouseLeavePreview()" #popover="ngbPopover">
<ng-content></ng-content>
</a>
<ng-template #previewContent>

View File

@ -131,9 +131,7 @@ describe('PreviewPopupComponent', () => {
it('should show preview on mouseover after delay to preload content', fakeAsync(() => {
component.mouseEnterPreview()
expect(component.popover.isOpen()).toBeTruthy()
expect(component.popoverHidden).toBeTruthy()
tick(600)
expect(component.popoverHidden).toBeFalsy()
component.close()
component.mouseEnterPreview()

View File

@ -38,7 +38,8 @@ export class PreviewPopupComponent implements OnDestroy {
@ViewChild('popover') popover: NgbPopover
mouseOnPreview: boolean
popoverHidden: boolean
popoverClass: string = 'shadow popover-preview'
get renderAsObject(): boolean {
return (this.isPdf && this.useNativePdfViewer) || !this.isPdf
@ -102,11 +103,11 @@ export class PreviewPopupComponent implements OnDestroy {
if (!this.popover.isOpen()) {
// we're going to open but hide to pre-load content during hover delay
this.popover.open()
this.popoverHidden = true
this.popoverClass = 'shadow popover-preview pe-none opacity-0'
setTimeout(() => {
if (this.mouseOnPreview) {
// show popover
this.popoverHidden = false
this.popoverClass = this.popoverClass.replace('pe-none opacity-0', '')
} else {
this.popover.close()
}
@ -119,6 +120,6 @@ export class PreviewPopupComponent implements OnDestroy {
}
public close() {
this.popover.close()
this.popover.close(false)
}
}