Coder Social home page Coder Social logo

jquery.magnifier's Introduction

jQuery.Magnifier

Create a magnifying glass for images (similar to what is used on eBay).

Initialize magnifier

$('img').magnifier(options);
$('img').magnifier();
$('img').magnifier({magnify:10, display:'#display', region:{h:39, w:39}});

Options

  • magnify - Amount to magnify by. Integer. Defaults to 5.
  • display - A selector or jQuery element that you wish to use to display the magnified images. Defaults to false.
  • region - This defines the width and height of the "magnifying glass" (dubbed the region). Should be defined as an object with properties "h" (for height) and "w" (for width) having defined integers. Defaults to the height and width being 20px.

The resulting display's size can be found by multipliying the region's dimensions by the magnify integer.

The region will disappear once a user moves their cursor off of the image. The display portal, wherever that is, will also disappear.

Before magnifier

<img src="elcoloso.jpg">

After magnifier (with display false)

<span class="mgnfr-dblwrap">
 <span class="mgnfr-wrapper" style="position:relative;display:inline-block;height:110px;width:100;overflow:hidden;">
  <img src="elcoloso.jpg" class="mgnfr-wrapped">
  <div class="mgnfr-region" style="height: 38.7px; width: 38.7px; background-color: rgba(128, 128, 128, 0.498039); outline: rgb(200, 200, 200) solid 1px; position: absolute; z-index: 3; top: 0px; left: 0px;"></div>
 </span>
 <div class="mgnfr-portal" style="overflow: hidden; height: 387px; width: 387px;">
  <img src="elcoloso.jpg" class="mgnfr-wrapped" style="height: 1100px; width: 1000px; transition: all 100ms linear; -webkit-transition: all 100ms linear; position: relative; top: 0px; left: 0px;">
 </div>
</span>

After magnifier (with display defined)

Around img element:

<span class="mgnfr-wrapper" style="position:relative;display:inline-block;height:110px;width:100;overflow:hidden;">
 <img src="elcoloso.jpg" class="mgnfr-wrapped">
 <div class="mgnfr-region" style="height: 38.7px; width: 38.7px; background-color: rgba(128, 128, 128, 0.498039); outline: rgb(200, 200, 200) solid 1px; position: absolute; z-index: 3; top: 0px; left: 0px;"></div>
</span>

Inside of display (only when currently magnifying):

<div id="display">
 <div class="mgnfr-portal" style="overflow: hidden; height: 387px; width: 387px;">
  <img src="elcoloso.jpg" style="height: 1100px; width: 1000px; transition: all 100ms linear; -webkit-transition: all 100ms linear; position: relative; top: 0px; left: 0px;">
 </div>
</div>

Remove magnifier

$('img').removeMagnifier();

License: Public Domain

Please don't rename it or change credit away from me, James Anthony Bruno, because that would make me sad. It is fine, however, to make changes to Magnifier's core to suit your needs for use in your products (whether commercial, personal, or non-profit). If you believe you've found a better way for Magnifier to work, go ahead and message me and let me know! I would love to implement your fix.

jquery.magnifier's People

Contributors

czycha avatar

Watchers

 avatar  avatar

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.