Jump to content
Search Community

Zooming with mouse wheel -- is there a library that integrates with GSAP?

qualityCode test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

I tried using svg-pan-zoom to zoom an svg via the mouse wheel.  It centers the zoom at the point of the mouse location. But I cannot get it to work with GSAP.  (The codepen shown here does not use svg-pan-zoom).  Does anyone know of an svg zoom library that zooms with the mouse and integrates with GSAP?

See the Pen VeRzKN by AlmaTheYounger (@AlmaTheYounger) on CodePen

Link to comment
Share on other sites

You can check out this post:

 

http://greensock.com/forums/topic/9213-control-draggable-with-mousewheelup-down-keys/#entry37139

 

Using jQuery to bind events for mousewheel. And your GSAP code would trigger inside the event handler:

 

And here is the MouseWheel event handler:

// MouseWheel event
$(document).unbind('mousewheel DOMMouseScroll').on('mousewheel DOMMouseScroll', function(evt) {

  var delta = (evt.originalEvent && evt.originalEvent.detail < 0) || evt.wheelDelta > 0 ? 1 : -1;

  if (delta < 0) {

      // scroll down
      console.log("scroll down");

   } else {

      // scroll up
      console.log("scroll up");
   }
});

I hope this helps! :)

  • Like 4
Link to comment
Share on other sites

  • 2 weeks later...

You can check out this post:

 

http://greensock.com/forums/topic/9213-control-draggable-with-mousewheelup-down-keys/#entry37139

 

Using jQuery to bind events for mousewheel. And your GSAP code would trigger inside the event handler:

 

And here is the MouseWheel event handler:

// MouseWheel event
$(document).unbind('mousewheel DOMMouseScroll').on('mousewheel DOMMouseScroll', function(evt) {

  var delta = (evt.originalEvent && evt.originalEvent.detail < 0) || evt.wheelDelta > 0 ? 1 : -1;

  if (delta < 0) {

      // scroll down
      console.log("scroll down");

   } else {

      // scroll up
      console.log("scroll up");
   }
});

I hope this helps! :)

This does not work in Chrome.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...