Comments (5)
I will take a look once I have time :)
from zooming.
Hey @p-4, I was about to reply to your email. Using data-zooming-width/height
with zooming.js means the image will always be zoomed to those dimensions, no matter the window size. The reason it works on my website is because I'm using a modified script with the changes mentioned above.
I have the modified script at https://github.com/migueldemoura/migueldemoura.com/blob/master/_assets/javascripts/zoom.js, but I advise you to please wait for the PR #61 to be closed.
from zooming.
@kingdido999, I just skimmed the code and added this quick fix. The user must provide the original image's size via data-zooming-width/height
.
calculateScale ()
//...
// Return the one that's smaller
var maxZoomingWidth = zoomingWidth / this.rect.width,
maxZoomingHeight = zoomingHeight / this.rect.height
if (zoomingHeight && zoomingWidth &&
scale > maxZoomingWidth || scale > maxZoomingHeight
) {
return {
x: maxZoomingWidth,
y: maxZoomingHeight
}
} else {
return {
x: scale,
y: scale
}
}
You'd need a control flag for this behaviour. I'm not using the other modes, hence why the condition looks like that.
Thanks for the plugin, appreciate it!
PS: I can submit a PR, just tell me how you'd like this to be exposed to the user
from zooming.
Yes, PR is welcome! Regarding the implementation, I have a few thoughts on top of my head:
- We might want to extend the existing option
customSize
so it accepts value in percentage. In this use case,customSize: ‘100%’
, which means it should zoom into at most the original size. - We should be able to read the original image size in our program without having user specify them explicitly through data attributes.
Please feel free to bring up any concerns or questions :)
from zooming.
I am trying to implement this, although I have very limited coding experience.
After providing the original image size with:
<img src="./images/image_name_small.jpg" data-action="zoom" data-zooming-width="1080" data-zooming-height="428" data-original="./images/image_name.jpg" />
The image is zoomed at maximum to its original dimensions. Nice!
Although, when the browser window is smaller than these max width/height, then when the image is zoomed, the image is bigger than the actual visible browser window area.
Where would one put the code @migueldemoura posted?
Or how I could keep the image within the borders of the actual browser window?
from zooming.
Related Issues (20)
- Switch to original image before animation
- Seeking Maintainers HOT 2
- there is differents between 2 situations HOT 1
- it did not work for me HOT 2
- Can I have more control over when zoom closes?
- Acess the template wrapper HOT 1
- zooming videos HOT 4
- Images are not zoomed in the center of the viewport when document is displayed within an iframe HOT 3
- Strange behavior when zoom animation is activated HOT 3
- further zoom in HOT 5
- Add option for cursor customization HOT 1
- Scale to full size of high res image. HOT 1
- Add config option to specify parent container for overlay
- click once to resize HOT 4
- Thanks for an excellent tool! HOT 1
- Closing on scroll doesn't occur as expected
- Implement event delegation!
- No zooming when img as link HOT 2
- Add an id to zoomed image or zoom div?
- Grab Strength/Distance
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zooming.