Git Product home page Git Product logo

Comments (7)

kingdido999 avatar kingdido999 commented on June 7, 2024

No, I think zoom on hover would cause poor user experience and inconsistent behavior between desktop and touch device.

from zooming.

kingdido999 avatar kingdido999 commented on June 7, 2024

@timrombergjakobsson However, you can achieve this by simply adding an event listener to your images, then use API to open up the image. Something like this:

const zooming = new Zooming()

// listen() takes either a single Element or, in this case, a CSS selector
zooming.listen('.zoomable')

const zoomable = document.getElementsByClassName('zoomable')

for (let i = 0; i < zoomable.length; i++) {
  const img = zoomable[i]
  img.addEventListener('mouseenter', function onMouseEnter (event) {
    zooming.open(event.target)
  })
  
  img.addEventListener('mouseleave', function onMouseLeave (event) {
    zooming.close()
  })
}

JSFiddle

from zooming.

timrombergjakobsson avatar timrombergjakobsson commented on June 7, 2024

Ok, thanks!

from zooming.

timrombergjakobsson avatar timrombergjakobsson commented on June 7, 2024

Hm weird, I tried your example I only get Uncaught TypeError: zooming.listen is not a function? I tried console loging the instance of Zooming and its there but the function listen does not seem to exist?

from zooming.

kingdido999 avatar kingdido999 commented on June 7, 2024

@timrombergjakobsson Here is a working example. I updated the previous comment as well.

from zooming.

timrombergjakobsson avatar timrombergjakobsson commented on June 7, 2024

@kingdido999 Thanks a lot!

from zooming.

armbull avatar armbull commented on June 7, 2024

About example
When photo was zoomed via hover event if you begin to grab and your mouse is outside of image, photo is zooming out and it doesn't work anymore. It works only after reload a page.
How to fix it?

from zooming.

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.