Code Monkey home page Code Monkey logo

easyzoom's Introduction

EasyZoom, jQuery image zoom plugin

EasyZoom is an elegant, highly optimised jQuery image zoom and panning plugin based on the original work by Alen Grakalic. EasyZoom supports touch-enabled devices and is easily customisable with CSS. It's been trusted for years by hundreds of thousands of websites including many well known brands like Patagonia, Gillette, Sports Direct, Topshop and Topman, Amara, Mary Kay, Dremel, Little Greene, iFixit, and many more.

Dependencies

jQuery 1.7+

Compatible with jQuery 1.x, 2.x and 3.x (inc. slim).

Issues

Have a bug? Please report an issues on the Github project page

https://github.com/i-like-robots/EasyZoom/issues

Versioning

Releases will be numbered in following format:

<major>.<minor>.<patch>

License

This work is licensed under a MIT License.

Authors

This jQuery plugin was written by Matt Hinchliffe.

Thanks also for contributions from:

easyzoom's People

Contributors

amaltsev avatar bobyhrp avatar fdiskas avatar federicobadini avatar funkjedi avatar humancopy avatar i-like-robots avatar leoquijano avatar slindstr avatar spescina avatar zarneckin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

easyzoom's Issues

click on image redirects to "zoom image" url if page loads slowly

Hi,

When a page loads very slowly, if I click on the image, instead of displaying the zoom image side-by-side, I am redirected to the zoom image's page.

For instance, in this case I get redirected to images/zoom.jpg:

<div class="easyzoom">
    <a href="images/zoom.jpg">
        <img src="images/standard.jpg" alt="" />
    </a>
</div>

A quick fix is to add onclick="return false;" such as:

<div class="easyzoom">
    <a href="images/zoom.jpg" onclick="return false;">
        <img src="images/standard.jpg" alt="" />
    </a>
</div>

new option request

can you please add a mask around the mouse pointer to highlight the zoomed area like amazon zoom feature?

Thanks,
Dony

Bug: zoom for wide images is hidden on hover

In my project I noticed a strange problem. The adjacent zoom I'm using was sometimes not working on wide images (small height, larger width). So once you hover over such an image sometimes the zoom images is not shown.

I looked a bit deeper into the problem and I found the problem:

if (xl < 0 || xt < 0 || xl > dw || xt > dh) {
    this.hide();
}

Sometimes when you start hovering over such an image hide gets called instantly in this part of the code. So something seems to be wrong with the calculation for such image ratios.

I wonder why there even is this part of the code? I removed the condition so it just adjusts the css and it worked just fine because there is also the mouseleave event.

able to move the cursor into the flyout

Hi again,

I found that if you quickly move the mouse into the flyout window it stays active, and does not dissappear.

If I increase the distance via the margin, then there is less chance of that happening but seems like a bug of sorts.

Bug on hovering image

Hey man, great work on the plugin :)

I know that in the plugin's site it is working flawlessly, but when I used the plugin I had to do a couple of things on your CSS:

.easyzoom-flyout {
    position:absolute;
    z-index: 100;
    overflow: hidden;
    background: #FFF;
    /* added all below */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

For some reason, this div was below the container of the smaller image, with no width neither height, and with overflow hidden. and since the image inside .easyzoom-flyout had a absolute position, it was not appearing.

I know it's probably something in the structure of my website, but just to make sure you are aware of it :)

Ah, I was using the inside style of the plugin (appearing the image over the smaller image).

Multiple images

When i using the multiple images ,after changing the image the zoom image is considering first image instead of the selected image.when we try to callback _init() its not working

Callbacks onInit, onShow, onHide

Would it be possible to have options to add a callback when the plugin initializes successfully, when a hover event starts and when it ends? I think this would help those that need to track these events in the page (like me :)

Thank you!

IE8/XP Issue

I've been having issues with the this.$zoom variable returning undefined.

This breaks the first method call on it on line 105.

It appears the issue is in the _load method. The onload callback for the image assigned to the zoom variable was firing before this.$zoom = $(zoom); was called in the event the image was cached. This means that nothing was appended to the flyout element and the the show method failing with the above error.

It's late here, so let me know if I explained that badly :)

I managed to fix it by calling this.$zoom = $(zoom); on line 139 before the onload callback is defined as well as on line 160. Not the greatest or most elegant of fixes, however it appears to work. That's all I care about for now!

Mouse move

Listen for mousemove event to also display the panel. E.G. If users cursor is over the source image before EasyZoom loads.

Cannot reinitialise easyzoom after teardown()

Following a call to the teardown() method, it appears we cannot reinitialise the plugin. Instead the following line prevents the plugin being re-instantiated:

Line 233:

if ( ! $.data(this, 'easyZoom') ) {

This still returns false after a teardown.

We want the ability to change the zoom image after the user selects a different thumbnail which loads a new image without a page refresh. At the moment we need to comment out lines 233 and 235 in order to run the following line again a second time in the code, which works fine but feels wrong:

$('.easyzoom').easyZoom();

Is there currently a correct way to refresh the zoom image?

Can you provide an example?

Sorry to double-post, I just saw the other issue was closed. Would you be able to provide an example of EazyZoom disabled by default and toggle to enable the zoom? I can't quite get it to function properly.

Disable zoom while loading

If using a gallery the zoom must be disabled (and loading cursor displayed) while loading a source image.

refresh function missing

I have a situation where I must update an image on the fly when the user changes a color.
To make that work, I had to do the following, other tries did'nt work:
function updateDetailsPageImages(current_product) {
var newsrc = current_product.info['productimage'],
newimg = '';
$("#productimage").html(newimg);
var z = $(".easyzoom").easyZoom();
var api = z.data('easyZoom');
api.teardown();
z = $('.easyzoom').easyZoom();
..... more

Shouldn't there be a more elegant way?

Thanks for consideration
Uwe

Add .swap() method

Add a .swap() method to the API which will enable quick image changing, E.G.

api.swap("path/to/normal/image.jpg", "path/to/zoom/image.jpg");

Not zooming

It loads the image, shows the crosshairs cursor, but does use/zoom to the larger image.

Speed

Any way to control the speed of the zone being zoomed while going from top to bottom?

How to show zoom image at default?

I try this code to set zoom image show default, but it not working:

var $easyzoom = $('.easyzoom').easyZoom();
var api = $easyzoom.data('easyZoom');
api.show();

How to show zoom image at default?

Hover from left side

Hi,
Google Chrome: On Adjacent (or overlay) demo page, slowly move your mouse from left outside to right (inside).
Zoomed image does not appear.
Great plugin anyway.

After adding custom CSS, no longer appends flyout container

Your plugin looks great, I love how simple it is! However, I am having some issues...

If I simply load the js file and instantiate it in my global.js file, it works. I have also added the recommended css styles to my main stylesheet. It works, but I can't add the class "easyzoom--adjacent" or add an extra styles to .easyzoom-flyout to control the layout. It breaks the append method and then no flyout container is generated...

This seems incredibly strange to me, because css rules shouldn't break any js...

Here's a page with my example : https://iambornandbred.com/shop/04-featured-multiple-images/

I'm going to leave some custom CSS on it so you can see that the flyout container isn't getting created.

Let me know if you need to see anything else, thanks.

Zoom Rectangle

Is there anyway we can limit the viewport for zoom images to a rectangle?

Embedded CSS

It appears that embedded CSS does function properly. For example

p>

div class="easyzoom easyzoom--overlay">
    a href="images/1_zoom.jpg">
        <img src="images/1_standard.jpg" alt="" style="float:left; margin:0 5px 0 0;width:352px; height:403px;" />
    /a>
/div>

This is text that should wrap around the image.....

/p>

Fading panel gone?

Hello, Good to see you are still working on this. The previous version I was using the panel would fade quickly on rollover. What happened to that?

Cache $panel object

Rapid mouseover/mouseout events cause a stack of zoom panels due to variable being re-assigned to new object.

_move() doesn't properly detect if mouse is inside the image

I was having problems with the zoomed image not showing up when the mouse was slowly entering from the bottom of the source image. Even though the mouse was inside the image, the function _move() would call hide() anyway. I added the following to debug:

console.log("xl: " + xl + " xt: " + xt + " dw: " + dw + " dh: " + dh);

I found out that upon entry from the bottom, variable xt would be 52.08, and variable dh would be 52.

In the following operation:

if (xl < 0 || xt < 0 || xl > dw || xt > dh) {
this.hide();
}

You can see that dx (52.08) is greater than (52) and thus thinks that we are outside the bounds, even if this is not the case. As the mouse continues going up, dx keeps decreasing, but the zoomed image has already been hidden, and it doesn't show until you leave and enter the image again (from a different side).

I solved the issue by adding Math.floor() to the xt variable. Hope this helps anyone having same issue.

Tip: Foundation can keep image flyout from appearing

I'm using Foundation 5 and EasyZoom 2.3.0.

Out of the box, Foundation sets a global rule for img tags of max-width: 100%. If you are trying to use the same image but with a css scale tranform, like
.easyzoom-flyout img { transform: scale(2); }
Then you'll need to make sure that images in the easyzoom don't have a max-width rule.

.easyzoom-flyout img {
    transform: scale(2);
    max-width: none;
} 

Otherwise, EasyZoom will trigger the show and then immediately the hide events. I didn't look through the code here but I'm guessing EasyZoom checks to see if it's necessary to zoom at all, or maybe it keeps the mouse move positioning from looking weird if the image isn't zoomed at all.

Hope this helps someone

Not an issue: Testing EasyZoom jQuery library on iPad Air & Android

Hi guys, I was not sure where to put this as I could not find how to contact you Matt.

Just to say that I just did a quick test of EasyZoom jQuery library with the following setup & it worked just fine on those devices:

  1. Apple iPad Air (see http://support.apple.com/kb/HT5452#ipad5 ), using Safari browser
  2. Apple iPad Air (see http://support.apple.com/kb/HT5452#ipad5 ), using Chrome browser
  3. Samsung S3 Mini, running on Android 4.1.2, using Chrome browser
  4. Samsung S3 Mini, running on Android 4.1.2, using Firefox browser

Thanks for writting this plugin.

Updating Zoomed Image with new URL

Thanks for the quick response on the last issue I had... I have it resolved now.

However, I'm using a little bit of js work to update the link href and main display image when a user clicks a thumbnail. The idea was that they could click the thumb, the main image would switch, and then on hover they would get a zoomed in version for detail.

This isn't working because I think the first image that a user hovers over gets cached, so when a user clicks a different thumbnail, it pulls up the original image even though the link href has been updated.

Any idea how I can patch this so easyzoom checks to see if the url has changed?

Change must be more elegant

If a user is using the gallery, clicks to load a new a new source image and moves back over the current source to view the full size image the zoom panel is removed and not reinstated. While it could be re-loaded on mousemove this is not satisfactory and could be prone to falling out of sync (due to functionality of the start() and loop() methods).

Instead, do not remove the panel and swap the full size image. This will require a separate method within the gallery extension.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.