D3 v4 - add transition to just zoom and not pan/drag

Keven

I would like to use a transition on all of my elements while zooming, but not while panning.

OPTION 1: I'd like to interrupt the transition while panning, but keep it while zooming. I've tried doing so with multiple methods, including the below, but nothing is working.

  .call(vis.zoom)
  .on("mousedown.zoom", function() {
    d3.interrupt(this);  <------------------ DOESN'T WORK
  });

OPTION 2: I'm also open to a second option, where if I click a zoom button, a transition is only added at that point to all elements in the SVG. Again, I've tried things like the below with no success.

function zoomIn() {
  timeline.zoom.scaleBy(timeline.svg, 1.5);
  timeline.svg.transition().duration(1000); <----- DOESN'T WORK
  timeline.wrangleData();
}

FULL EXAMPLE: https://jsfiddle.net/kre96sdy/2/

Keven

I was able to figure it out on my own (using OPTION 2) with the help of a recent addition of a reset button which Mike Bostock added to this gist:

https://bl.ocks.org/mbostock/db6b4335bf1662b413e7968910104f0f

function resetted() {
  svg.transition()
    .duration(750)
    .call(zoom.transform, d3.zoomIdentity);
}

You can see that he just added a transition to the reset button, so zooming/panning with the mouse are unaffected.

So in my case I did the below and it works great:

function zoomIn() {
  timeline.svg.transition()
    .duration(750)
    .call(timeline.zoom.scaleBy, 1.5)
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to add the filter or ScaleExtent in d3 v4 in Timeline with Zoom functionality

From Dev

D3 V4 setting initial zoom level

From Dev

D3 v4 add another node to array

From Dev

D3 v4 - d3.zoom() prevents binding some events except on the Window

From Dev

How to make a clickable transition bar graph to show 3 graphs in d3 v4?

From Dev

D3 add zoom to circle pack

From Dev

D3 V4 How to move dots according to zoom in linechart?

From Dev

Avoid unzooming/zooming transition while updating zoom on d3

From Dev

Avoid unzooming/zooming transition while updating zoom on d3

From Dev

How to make a clickable transition bar graph in d3 v4?

From Dev

d3 transition: update axis and data just once

From Dev

React Router v4 component transition with ReactCSSTransitionGroup add-on

From Dev

Horizontal zoom with D3 version 4?

From Dev

Is it possible to modify the zoom transition in Google Maps V3?

From Java

Add a Toggle function to d3 tree chart v4

From Dev

Dynamically Add/Remove Lines in d3 (v4) Line Chart

From Dev

D3: Add element after delay, then transition

From Dev

Apply zoom event on existing SVG (d3.js v4)

From Dev

Erratic zoom on force directed graph with D3.js v4

From Dev

d3.js v4 wacky link transition in collapsible tree example

From Dev

d3 zoom and pan upgrade to version 4

From Dev

d3 version 4 zoom behaviour on g element

From Dev

In D3.JS Is there a way to add on to a line, one point at a time, using D3 transition?

From Dev

d3.js zoom transition with map tiles

From Dev

d3v4 - 'transition' of undefined

From Dev

Transition errors in d3.v4

From Dev

d3 stacking and zoom

From Dev

How do I add a transition delay between multiple individual transitioning polygons in D3?

From Dev

D3: When I add a transition, my mouseover stops working... why?

Related Related

  1. 1

    How to add the filter or ScaleExtent in d3 v4 in Timeline with Zoom functionality

  2. 2

    D3 V4 setting initial zoom level

  3. 3

    D3 v4 add another node to array

  4. 4

    D3 v4 - d3.zoom() prevents binding some events except on the Window

  5. 5

    How to make a clickable transition bar graph to show 3 graphs in d3 v4?

  6. 6

    D3 add zoom to circle pack

  7. 7

    D3 V4 How to move dots according to zoom in linechart?

  8. 8

    Avoid unzooming/zooming transition while updating zoom on d3

  9. 9

    Avoid unzooming/zooming transition while updating zoom on d3

  10. 10

    How to make a clickable transition bar graph in d3 v4?

  11. 11

    d3 transition: update axis and data just once

  12. 12

    React Router v4 component transition with ReactCSSTransitionGroup add-on

  13. 13

    Horizontal zoom with D3 version 4?

  14. 14

    Is it possible to modify the zoom transition in Google Maps V3?

  15. 15

    Add a Toggle function to d3 tree chart v4

  16. 16

    Dynamically Add/Remove Lines in d3 (v4) Line Chart

  17. 17

    D3: Add element after delay, then transition

  18. 18

    Apply zoom event on existing SVG (d3.js v4)

  19. 19

    Erratic zoom on force directed graph with D3.js v4

  20. 20

    d3.js v4 wacky link transition in collapsible tree example

  21. 21

    d3 zoom and pan upgrade to version 4

  22. 22

    d3 version 4 zoom behaviour on g element

  23. 23

    In D3.JS Is there a way to add on to a line, one point at a time, using D3 transition?

  24. 24

    d3.js zoom transition with map tiles

  25. 25

    d3v4 - 'transition' of undefined

  26. 26

    Transition errors in d3.v4

  27. 27

    d3 stacking and zoom

  28. 28

    How do I add a transition delay between multiple individual transitioning polygons in D3?

  29. 29

    D3: When I add a transition, my mouseover stops working... why?

HotTag

Archive