information details:
I have an image editor where I'm tracking a click and drag to re-position an image using background-position
. I want to auto center the image and allow the click and drag functionality. I could use center
or 50%
but the click and drag is using pixels so it's preferable that I:
- find the image width and height (I'm struggling to do this)
- find the wrapping div width and height (I can do this just fine)
- calculate the center of both in pixels and set those values in
background-position
I'm using the javascript File Loader API in a class
like so:
this.reader.onload = file => {
// setting image on class via `this.reader.result`
};
How do I get the width and height of the file while carrying context with the fat-arrow? Is it possible?