Skip to content

Commit

Permalink
Merge branch 'two' into tapDistance-180
Browse files Browse the repository at this point in the history
  • Loading branch information
Fil committed Jul 24, 2020
2 parents 3318746 + 87c6215 commit e02e23c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 30 deletions.
19 changes: 0 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,25 +261,6 @@ When a [zoom event listener](#zoom_on) is invoked, it receives the current zoom
* *event*.transform - the current [zoom transform](#zoom-transforms).
* *event*.sourceEvent - the underlying input event, such as mousemove or touchmove.

The *event* object also exposes the [*event*.on](#event_on) method.

<a href="#event_on" name="event_on">#</a> <i>event</i>.<b>on</b>(<i>typenames</i>, [<i>listener</i>]) · [Source](https://github.com/d3/d3-zoom/blob/master/src/event.js)

Equivalent to [*zoom*.on](#zoom_on), but only applies to the current zoom gesture. Before the zoom gesture starts, a [copy](https://github.com/d3/d3-dispatch#dispatch_copy) of the current brush [event listeners](#zoom_on) is made. This copy is bound to the current zoom gesture and modified by *event*.on. This is useful for temporary listeners that only receive events for the current zoom gesture. For example, this start event listener registers temporary zoom and end event listeners as closures:

```js
function started(event, d) {
d3.select(this).classed("zooming", true);
event.on("zoom", zoomed).on("end", ended);
function zoomed(event, d) {
console.log("zooming", d, "with", event.transform);
}
function ended(event, d) {
console.log("zoom on", d, "ended at", event.transform);
}
}
```

### Zoom Transforms

The zoom behavior stores the zoom state on the element to which the zoom behavior was [applied](#_zoom), not on the zoom behavior itself. This is because the zoom behavior can be applied to many elements simultaneously, and each element can be zoomed independently. The zoom state can change either on user interaction or programmatically via [*zoom*.transform](#zoom_transform).
Expand Down
5 changes: 0 additions & 5 deletions src/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,3 @@ export default function ZoomEvent(type, {
_: {value: dispatch}
});
}

ZoomEvent.prototype.on = function() {
var value = this._.on.apply(this._, arguments);
return value === this._ ? this : value;
};
9 changes: 3 additions & 6 deletions src/zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export default function() {
.on("touchstart.zoom", touchstarted)
.on("touchmove.zoom", touchmoved)
.on("touchend.zoom touchcancel.zoom", touchended)
.style("touch-action", "none")
.style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
}

Expand Down Expand Up @@ -195,7 +194,6 @@ export default function() {
start: function() {
if (++this.active === 1) {
this.that.__zooming = this;
this.dispatch = listeners.copy();
this.emit("start");
}
return this;
Expand All @@ -216,17 +214,16 @@ export default function() {
return this;
},
emit: function(type) {
var dispatch = this.dispatch,
d = select(this.that).datum();
dispatch.call(
var d = select(this.that).datum();
listeners.call(
type,
this.that,
new ZoomEvent(type, {
sourceEvent: this.sourceEvent,
target: zoom,
type,
transform: this.that.__zoom,
dispatch
dispatch: listeners
}),
d
);
Expand Down

0 comments on commit e02e23c

Please sign in to comment.