Git Product home page Git Product logo

image-zoom's Introduction

image-zoom

Zoom an image to full-screen, as seen on Medium.com. It uses transforms for buttery smoothness, but should still work on older browsers given polyfills for classList & bind. Demo here.

Using React? Try react-thumbnail-zoom instead.

Installation

Install using Duo or NPM for use with browserify.

$ npm install image-zoom
var Zoom = require('bmcmahen/image-zoom');

or use the standalone build in dist using the global Imagezoom.

API

You can use markup (much like Bootstrap) for initiating zoom on certain elements.

<img class='thumb' src='inst6.jpg' data-zoom-padding='20' data-zoom-url='inst6.jpg' data-zoom-overlay='true'>
<script src='imagezoom.js'></script>

Or you can use the javascript API, like in the example below.

<img class='thumb' src='inst6.jpg'>

<script>
var ImageZoom = require('image-zoom');

var img = document.querySelector('img');
var zoom = new Imagezoom(img).overlay().padding(350);

img.onclick = function(e){
  // stop propagation if we want to retain our HTML api
  // in other parts of the site.
  e.stopPropagation();
  zoom2.show();
};

// unbind our delegate listener if we aren't
// using the HTML api.
zoom.stopListening();

</script>

.show()

Zoom in.

.hide()

Zoom out.

.overlay()

Enable the overlay when zooming into the image.

.padding(num)

Set the padding of the zoomed image.

.use(plugin)

Use a plugin.

Events

showing

shown

hiding

hidden

cancel

var zoom = require('image-zoom');
var z = zoom(document.querySelector('img'));
z.on('shown', function(){
  // our element is zoomed in
});

License

MIT

image-zoom's People

Contributors

bmcmahen 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

Watchers

 avatar  avatar  avatar  avatar

image-zoom's Issues

support captions

optionally support captions - how do we handle this with regards to accessibility?

double zoom in

while zoomed in, if you click the original location of the image (when not using an overlay), the same image zooms in twice.

Loading Animation ?

I really love your plug-in. Simple, light and no-blurry images !
Can you throw me some ideas about how to add css loading effects.

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.