(lThis, d)
| 246 | } |
| 247 | |
| 248 | function dragend(lThis, d) { |
| 249 | var brush = d.brush; |
| 250 | var filter = brush.filter; |
| 251 | var s = brush.svgBrush; |
| 252 | |
| 253 | if(!s._dragging) { // i.e. click |
| 254 | // mock zero drag |
| 255 | mousemove(lThis, d); |
| 256 | drag(lThis, d); |
| 257 | // remember it is a click not a drag |
| 258 | d.brush.svgBrush.wasDragged = false; |
| 259 | } |
| 260 | s._dragging = false; |
| 261 | |
| 262 | var e = d3.event; |
| 263 | e.sourceEvent.stopPropagation(); |
| 264 | var grabbingBar = s.grabbingBar; |
| 265 | s.grabbingBar = false; |
| 266 | s.grabLocation = undefined; |
| 267 | d.parent.inBrushDrag = false; |
| 268 | clearCursor(); // instead of clearing, a nicer thing would be to set it according to current location |
| 269 | if(!s.wasDragged) { // a click+release on the same spot (ie. w/o dragging) means a bar or full reset |
| 270 | s.wasDragged = undefined; // logic-wise unneeded, just shows `wasDragged` has no longer a meaning |
| 271 | if(s.clickableOrdinalRange) { |
| 272 | if(brush.filterSpecified && d.multiselect) { |
| 273 | s.extent.push(s.clickableOrdinalRange); |
| 274 | } else { |
| 275 | s.extent = [s.clickableOrdinalRange]; |
| 276 | brush.filterSpecified = true; |
| 277 | } |
| 278 | } else if(grabbingBar) { |
| 279 | s.extent = s.stayingIntervals; |
| 280 | if(s.extent.length === 0) { |
| 281 | brushClear(brush); |
| 282 | } |
| 283 | } else { |
| 284 | brushClear(brush); |
| 285 | } |
| 286 | s.brushCallback(d); |
| 287 | renderHighlight(lThis.parentNode); |
| 288 | s.brushEndCallback(brush.filterSpecified ? filter.getConsolidated() : []); |
| 289 | return; // no need to fuse intervals or snap to ordinals, so we can bail early |
| 290 | } |
| 291 | |
| 292 | var mergeIntervals = function() { |
| 293 | // Key piece of logic: once the button is released, possibly overlapping intervals will be fused: |
| 294 | // Here it's done immediately on click release while on ordinal snap transition it's done at the end |
| 295 | filter.set(filter.getConsolidated()); |
| 296 | }; |
| 297 | |
| 298 | if(d.ordinal) { |
| 299 | var a = d.unitTickvals; |
| 300 | if(a[a.length - 1] < a[0]) a.reverse(); |
| 301 | s.newExtent = [ |
| 302 | ordinalScaleSnap(0, a, s.newExtent[0], s.stayingIntervals), |
| 303 | ordinalScaleSnap(1, a, s.newExtent[1], s.stayingIntervals) |
| 304 | ]; |
| 305 | var hasNewExtent = s.newExtent[1] > s.newExtent[0]; |
no test coverage detected
searching dependent graphs…