mirror of
https://github.com/fengyuanchen/viewerjs.git
synced 2026-02-01 16:32:50 +00:00
fix: append image to document to load correct size
This commit is contained in:
parent
5c569c7cf6
commit
fd4e721ad5
@ -526,12 +526,16 @@ export function getImageNaturalSizes(image, callback) {
|
||||
}
|
||||
|
||||
const newImage = document.createElement('img');
|
||||
const { body } = document;
|
||||
|
||||
newImage.onload = () => {
|
||||
callback(newImage.width, newImage.height);
|
||||
body.removeChild(newImage);
|
||||
};
|
||||
|
||||
newImage.src = image.src;
|
||||
newImage.style.cssText = 'position: absolute; top: 0; left: 0; z-index: -1; opacity: 0;';
|
||||
body.appendChild(newImage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user