mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
refactor: 💡 improve image zoom
This commit is contained in:
parent
df6c6647c7
commit
47a363be0f
@ -150,7 +150,7 @@ function renderImage(entity: FNote | FAttachment, $renderedContent: JQuery<HTMLE
|
||||
$renderedContent.append($img);
|
||||
|
||||
if (options.imageHasZoom) {
|
||||
setTimeout(() => {
|
||||
const initZoom = async () => {
|
||||
const element = document.querySelector(`#${$img.attr("id")}`);
|
||||
if (element) {
|
||||
WheelZoom.create(`#${$img.attr("id")}`, {
|
||||
@ -158,8 +158,11 @@ function renderImage(entity: FNote | FAttachment, $renderedContent: JQuery<HTMLE
|
||||
speed: 1.3,
|
||||
zoomOnClick: false
|
||||
});
|
||||
} else {
|
||||
requestAnimationFrame(initZoom);
|
||||
}
|
||||
}, 0);
|
||||
};
|
||||
initZoom();
|
||||
}
|
||||
|
||||
imageContextMenuService.setupContextMenu($img);
|
||||
|
@ -54,7 +54,7 @@ class ImageTypeWidget extends TypeWidget {
|
||||
this.$imageWrapper = this.$widget.find(".note-detail-image-wrapper");
|
||||
this.$imageView = this.$widget.find(".note-detail-image-view").attr("id", `image-view-${utils.randomString(10)}`);
|
||||
|
||||
setTimeout(() => {
|
||||
const initZoom = async () => {
|
||||
const element = document.querySelector(`#${this.$imageView.attr("id")}`);
|
||||
if (element) {
|
||||
WheelZoom.create(`#${this.$imageView.attr("id")}`, {
|
||||
@ -62,8 +62,11 @@ class ImageTypeWidget extends TypeWidget {
|
||||
speed: 1.3,
|
||||
zoomOnClick: false
|
||||
});
|
||||
} else {
|
||||
requestAnimationFrame(initZoom);
|
||||
}
|
||||
}, 0);
|
||||
};
|
||||
initZoom();
|
||||
|
||||
imageContextMenuService.setupContextMenu(this.$imageView);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user