Skip to content

Commit

Permalink
remove zoomEvent.on for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Fil committed Jul 24, 2020
1 parent 87781b6 commit 96bd44b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 29 deletions.
19 changes: 0 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,25 +257,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;
};
8 changes: 3 additions & 5 deletions src/zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,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 @@ -214,17 +213,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 96bd44b

Please sign in to comment.