Skip to content

Commit

Permalink
optimise preview
Browse files Browse the repository at this point in the history
  • Loading branch information
ra3orblade committed Jan 12, 2024
1 parent a9f1f56 commit 8eb40e5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/ts/lib/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Preview {
delay: 0,
};
delayTooltip = 0;
isPreviewOpen = false;

/**
* Displays a tooltip with the given text and position relative to the specified element.
Expand Down Expand Up @@ -190,15 +191,20 @@ class Preview {
} else {
commonStore.previewSet(param);
};

this.isPreviewOpen = true;
};

/**
* Hides preview, if any is being shown.
* @param force - hide the preview immediately, without 250ms delay
*/
previewHide (force?: boolean) {
const obj = $('#preview');
if (!this.isPreviewOpen) {
return;
};

const obj = $('#preview');
const cb = () => {
obj.hide();
obj.removeClass('anim top bottom withImage').css({ transform: '' });
Expand All @@ -215,6 +221,8 @@ class Preview {
obj.css({ opacity: 0, transform: 'translateY(0%)' });
this.timeout.preview = window.setTimeout(() => cb(), DELAY_PREVIEW);
};

this.isPreviewOpen = false;
};

/**
Expand Down

0 comments on commit 8eb40e5

Please sign in to comment.