Giter VIP home page Giter VIP logo

Comments (9)

jackmoore avatar jackmoore commented on June 9, 2024

Ok, I think I see what the issue is. The zoom plugin is based on the natural width and height of the image. The default zoom magnify multiplier is 1 (100%), so if you are already showing your zoomed image at full size there is no visible change. You can try setting the magnify property to a value larger than 1 for the effect to be applied to images already at their full size. For example, using code from your page:

  $('img')
    .wrap('<span style="display:inline-block"></span>')
    .css('display', 'block')
    .parent()
    .zoom({magnify: 2});

from zoom.

gmuse avatar gmuse commented on June 9, 2024

Thank you Jack, that did the trick!

Also, how do I exclude some pictures from the zoom?

This line doesn't seem to do it:
$('#pic1').trigger('zoom.destroy');

Is it because the javascript setting on the img element overrides this?

from zoom.

jackmoore avatar jackmoore commented on June 9, 2024

You are assigning zoom to the parent element, so you would do this instead:

$('#pic1').parent().trigger('zoom.destroy');

However, it would be better to exclude images before assigning:

 $('img:not(#pic1)')
    .wrap('<span style="display:inline-block"></span>')
    .css('display', 'block')
    .parent()
    .zoom({magnify: 2});

My advice would be to give the images you want to use zoom with their own class, so that it's opt-in rather than opt-out.

from zoom.

gmuse avatar gmuse commented on June 9, 2024

Hey Jack, one last question. I'm new to this. I have already given the images I want to use zoom with their own class. How do I incorporate it into the javascript?

from zoom.

Luphrid avatar Luphrid commented on June 9, 2024

The zoom images automatically get a class of "zoomImg" when they are put on the page.

from zoom.

gmuse avatar gmuse commented on June 9, 2024

Right, but he said his advice would be to give the images you want to use zoom with their own class, so that it's opt-in rather than opt-out. I'm trying to only use zoom on certain images on the page. Right now I have it setup so any img element gets the zoom (below), and trying to figure out how to insert the class that I setup into that code so that only images with the class then get the class zoomImg.

$(document).ready(function(){
  $('img')
    .wrap('<span style="display:inline-block"></span>')
    .css('display', 'block')
    .parent()
    .zoom({magnify:1.5});
});

from zoom.

Luphrid avatar Luphrid commented on June 9, 2024

Oh I see! You just need to modify your selector.

$(document).ready(function(){
  $('.yourNewClass')
    .wrap('<span style="display:inline-block"></span>')
    .css('display', 'block')
    .parent()
    .zoom({magnify:1.5});
});

from zoom.

gmuse avatar gmuse commented on June 9, 2024

Ha, wow, okay thank you!

from zoom.

Luphrid avatar Luphrid commented on June 9, 2024

You are welcome.

from zoom.

Related Issues (20)

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.