Git Product home page Git Product logo

zoom.js's Introduction

zoom.js

Enables a minimal JS API for zooming in on specific points or DOM elements.

Note that this is only a proof of concept so don't use it for anything important. Does not work in IE, yet.

Try out the demo.

Usage

Zoom in on an element:

  zoom.to({
    element: document.querySelector( 'img' )
  });

Additional options:

  zoom.to({
    element: document.querySelector( 'img' ),

    // Amount of empty space around zoomed element
    padding: 20,

    // Function to call once zooming completes
    callback: function() { /* ... */ }
  });

Zoom in on a point:

  zoom.to({
    x: 100,
    y: 200,
    width: 300,
    height: 300
  });
  zoom.to({
    x: 100,
    y: 200,
    scale: 3
  });

Reset

  zoom.out();

License

MIT licensed

Copyright (C) 2017 Hakim El Hattab, http://hakim.se

zoom.js's People

Contributors

hakimel avatar lennardv2 avatar lyuggang 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  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

zoom.js's Issues

Zooming Out After Panning Bug

Seems that zooming out doesn't take the panned location into account when zooming back out.

To demonstrate the problem zoom in on the box labelled "Float" then pan down to the unicorn.

Once there, click on the unicorn.

zoom.js on ipad?

Hi,
I am using zoom js to zoom the grid images for website, it's really great on the browsers.
But it's on ipad looks a bit like out of focus, do you have any solutions for that?

Thanks!
Best,
HYC

Is zoom.to supposed to work for element and position at same time?

Both element and x, y coordinates can be set as options in this library.
However, it is not clear what x and y are relative to and whether element and coordinates can be used together. What I mean by used together is that the zoom would focus to a point within the element rather than always the center.

Please could somebody clarify.
Regards.

Can't scroll left after zoom

When I zoom, I can pan right, up, and down as the add-on page suggests, but the horizontal scrollbar position always seems locked at the very left, so I can't scroll left.

Is it possible to fix this please? I see the last commit is years ago, it would be awesome if this can be fixed! I haven't tried yet digging into the source.

Old IE support

You could probably use zoom to make this work (without the transition) in old IEs :)

css transform issue

Hi am trying to use the zoom.js but getting error
Uncaught TypeError: Cannot read property 'style' of null
What to do any suggestion plz

Element undefined

I am trying out zoom.js to zoom in on the div that are inside a container div. The target is not undefined but I keep on getting this error:
Uncaught TypeError: Cannot read properties of undefined (reading 'to'). Does the element needs to have a certain attribute to be able to pass in as element?

Below is the code I'm using:

document.querySelector("#outerContainer").addEventListener('wheel', function(event) {
event.preventDefault();
zoom.to({ element: event.target, padding:20 });
});

A bookmarklet would be nice

I actually believe I would use this every now and then if I had a bookmarklet to activate it when I need it.

IE9 support

Zooms in on wrong location. Also IE is not OK with naming a method in as it conflicts with the operator; perhaps zoom.magnify()?

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.