ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I could not find it on google, and I'd also like to avoid using jquery and similar plugins if possible.
I'm not very experienced with javascript - I know it's going to involve onmouseover() and getElementById(), but I can't think of how to make just part of the image magnified - whole image would not be a problem.
Thank you for your answer,
I'm expecting it to be something like that, but I don't know how to 'select' just a part of the picture to be in the external block element.
but I don't know how to 'select' just a part of the picture to be in the external block element.
You don't need to, you're just shifting the position of the larger image around in its container. The "overflow:hidden" deals with keeping it "in the box".
You don't need to, you're just shifting the position of the larger image around in its container. The "overflow:hidden" deals with keeping it "in the box".
So how do I get the position of the mouse in relation to picture, so I know how much should I shift the big one?
Did you saw my code? There are three lines of simple javascript code to compute what you want. To get X and Y position of mouse pointer you can use "aEvent.clientX" and "aEvent.clientY" from mousemove event. Then you shift it by offset of small image and multiply by scale (ZoomedImage.width / 50) width of big image divided by width of small image, and then shift by half of big image, to move big image to center.
Did you saw my code? There are three lines of simple javascript code to compute what you want. To get X and Y position of mouse pointer you can use "aEvent.clientX" and "aEvent.clientY" from mousemove event. Then you shift it by offset of small image and multiply by scale (ZoomedImage.width / 50 width of big image divided by width of small image and then shift by half of big image, to move big image to center.
Whoa, for some reason, I didn't see the code at all - I thought you're just vaguely referring to the solution. Thanks, I'll check it out.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.