{"action":"created","issue":{"url":"https://api.github.com/repos/d3/d3-brush/issues/22","repository_url":"https://api.github.com/repos/d3/d3-brush","labels_url":"https://api.github.com/repos/d3/d3-brush/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/d3/d3-brush/issues/22/comments","events_url":"https://api.github.com/repos/d3/d3-brush/issues/22/events","html_url":"https://github.com/d3/d3-brush/issues/22","id":187644503,"number":22,"title":"Cannot avoid brush selection reset ","user":{"login":"AlainRo","id":1700044,"avatar_url":"https://avatars.githubusercontent.com/u/1700044?v=3","gravatar_id":"","url":"https://api.github.com/users/AlainRo","html_url":"https://github.com/AlainRo","followers_url":"https://api.github.com/users/AlainRo/followers","following_url":"https://api.github.com/users/AlainRo/following{/other_user}","gists_url":"https://api.github.com/users/AlainRo/gists{/gist_id}","starred_url":"https://api.github.com/users/AlainRo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlainRo/subscriptions","organizations_url":"https://api.github.com/users/AlainRo/orgs","repos_url":"https://api.github.com/users/AlainRo/repos","events_url":"https://api.github.com/users/AlainRo/events{/privacy}","received_events_url":"https://api.github.com/users/AlainRo/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-07T07:43:45Z","updated_at":"2016-11-07T15:08:03Z","closed_at":"2016-11-07T15:08:03Z","body":"A click in the extent outside the selection rectangle reset the 2D brush selection to null. Fair enough.\r\nBut is it possible to take control of this behavior which occurs before the brush start event ??\r\n\r\nThis issue can be seen in this example:\r\nhttp://bl.ocks.org/AlainRo/9264cd08e341f2c92f020c39642c34d1"},"comment":{"url":"https://api.github.com/repos/d3/d3-brush/issues/comments/258860353","html_url":"https://github.com/d3/d3-brush/issues/22#issuecomment-258860353","issue_url":"https://api.github.com/repos/d3/d3-brush/issues/22","id":258860353,"user":{"login":"mbostock","id":230541,"avatar_url":"https://avatars.githubusercontent.com/u/230541?v=3","gravatar_id":"","url":"https://api.github.com/users/mbostock","html_url":"https://github.com/mbostock","followers_url":"https://api.github.com/users/mbostock/followers","following_url":"https://api.github.com/users/mbostock/following{/other_user}","gists_url":"https://api.github.com/users/mbostock/gists{/gist_id}","starred_url":"https://api.github.com/users/mbostock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbostock/subscriptions","organizations_url":"https://api.github.com/users/mbostock/orgs","repos_url":"https://api.github.com/users/mbostock/repos","events_url":"https://api.github.com/users/mbostock/events{/privacy}","received_events_url":"https://api.github.com/users/mbostock/received_events","type":"User","site_admin":false},"created_at":"2016-11-07T15:08:03Z","updated_at":"2016-11-07T15:08:03Z","body":"As I like to say, everything is possible, it’s just a question of how much work is involved. You have a few options:\r\n\r\n* Remove the overlay element from the brush after applying it.\r\n\r\n```js\r\nsvg.append(\"g\")\r\n    .attr(\"class\", \"brush\")\r\n    .call(d3.brush().on(\"brush\", brushed))\r\n  .selectAll(\".overlay\")\r\n    .remove();\r\n```\r\n\r\n* Register a listener that takes priority for input events that would initiate a brush gesture, namely *mousedown* or *touchstart*. See https://github.com/d3/d3-zoom/issues/66#issuecomment-255175895 for a related discussion of event propagation; probably the easiest thing is to use a capturing event listener and then call *event*.stopImmediatePropagation (or *event*.stopPropagation) to prevent the brush from receiving the initiating input event.\r\n\r\n* Use [*brush*.filter](https://github.com/d3/d3-brush/blob/master/README.md#brush_filter) to tell the brush to ignore input events on the overlay (using *event*.target to detect the receiving element; see [brush.js](https://github.com/d3/d3-brush/blob/master/src/brush.js#L296)), so that they won’t start a brush gesture.\r\n\r\n* Use a *start* [brush event listener](https://github.com/d3/d3-brush/blob/master/README.md#brush-events) to set the brush selection to something other than null as desired. See [Brush Snapping II](https://bl.ocks.org/mbostock/6232620) for an example, although note that this doesn’t snap the brush on *start* (because it intentionally preserves the normal brush behavior of letting you clear the brush selection by clicking on the background).\r\n\r\nIf you have further questions, please use [Stack Overflow tag d3.js](https://stackoverflow.com/tags/d3.js) to ask for help. Although I make an effort to assist everyone that asks, I am not always available to provide help promptly or directly. Stack Overflow provides a better collaborative forum for self-help: tens of thousands of D3-related questions have already been asked there, and some answered questions may be relevant to you.\r\n\r\nIf you have a question about D3’s behavior and want to discuss it with other users, also consider the [d3-js Google Group](https://groups.google.com/forum/#!forum/d3-js) or [joining](https://d3-slackin.herokuapp.com/) the [d3-js Slack](https://d3js.slack.com/).\r\n\r\nThank you! 🤗\r\n"}}
{"actor":{"display_login":"mbostock"}}