How to use the d3-selection.event.preventDefault function in d3-selection

To help you get started, we’ve selected a few d3-selection examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstreetmap / iD / modules / ui / raw_member_editor.js View on Github external
function downloadMember(d) {
        d3_event.preventDefault();

        // display the loading indicator
        d3_select(this.parentNode).classed('tag-reference-loading', true);
        context.loadEntity(d.id, function() {
            updateDisclosureContent(_contentSelection);
        });
    }
github UXAspects / UXAspects / src / components / organization-chart / organization-chart.component.ts View on Github external
// if the node is collapsed and has children expand
                if (!node.data.expanded && Array.isArray(node.data.children) && node.data.children.length > 0) {
                    return this.expand(node);
                }
                return this.focusChild(node);

            case RIGHT_ARROW:
                event.preventDefault();
                return this.focusNextSibling(node);

            case UP_ARROW:
                event.preventDefault();
                return this.focusParent(node);

            case LEFT_ARROW:
                event.preventDefault();
                return this.focusPreviousSibling(node);

            case ENTER:
                return this.toggle(node);
        }
    }
github openstreetmap / iD / modules / ui / disclosure.js View on Github external
function toggle() {
            d3_event.preventDefault();

            _expanded = !_expanded;

            if (_updatePreference) {
                context.storage('disclosure.' + key + '.expanded', _expanded);
            }

            hideToggle
                .classed('expanded', _expanded);

            hideToggle.selectAll('.hide-toggle-icon')
                .attr('xlink:href', _expanded ? '#icon-down'
                    : (textDirection === 'rtl') ? '#icon-backward' : '#icon-forward'
                );

            wrap
github openstreetmap / iD / modules / ui / feature_list.js View on Github external
function click(d) {
            d3_event.preventDefault();
            if (d.location) {
                context.map().centerZoomEase([d.location[1], d.location[0]], 19);
            }
            else if (d.entity) {
                if (d.entity.type === 'node') {
                    context.map().center(d.entity.loc);
                } else if (d.entity.type === 'way') {
                    var center = context.projection(context.map().center());
                    var edge = geoChooseEdge(context.childNodes(d.entity), center, context.projection);
                    context.map().center(edge.loc);
                }
                context.enter(modeSelect(context, [d.entity.id]));
            } else {
                context.zoomToEntity(d.id);
            }
        }
github openstreetmap / iD / modules / ui / taskingTaskDetails.js View on Github external
click: function zoomTo() {
                d3_event.preventDefault();
                d3_event.stopPropagation();
                context.layers().layer('tasking').fitZoom();
            }
        }];
github denisemauldin / d3-timeline / src / timelines.js View on Github external
g.on("wheel", function() {
					event.preventDefault();
					event.stopImmediatePropagation();
				});
				g.on("dblclick.zoom", function() {
github Datawheel / canon / packages / cms / src / components / fields / ProfileSearch.jsx View on Github external
ENTER = 13,
            ESC = 27,
            LEFT = 37,
            UP = 38,
            RIGHT = 39;

      const arrowKeys = display === "columns" ? [LEFT, UP, RIGHT, DOWN] : [UP, DOWN];
      const linkHighlighted = isDescendant(this.resultContainer, event.target);
      const tagName = event.target.tagName.toLowerCase();

      if (activeKeyCode !== false && key === activeKeyCode && !["input", "textarea"].includes(tagName)) {
        event.preventDefault();
        this.textInput.focus();
      }
      else if (key === ESC && event.target === this.textInput) {
        event.preventDefault();
        this.textInput.blur();
      }
      else if (key === DOWN && event.target === this.textInput) {
        event.preventDefault();
        const firstLink = select(this.resultContainer).select("a");
        if (firstLink.size()) firstLink.node().focus();
      }
      else if (arrowKeys.includes(key) && linkHighlighted) {

        event.preventDefault();

        if (key === DOWN) {
          const nextLink = findSibling(event.target, "next");
          if (nextLink) this.scrollToLink.bind(this)(nextLink);
        }
        else if (key === UP) {
github graphsense / graphsense-dashboard / src / nodeGraph / addressNode.js View on Github external
.on('contextmenu', () => {
          event.stopPropagation()
          event.preventDefault()
          this.dispatcher('contextmenu', {x: event.x, y: event.y, node: this})
        })
      g.append('rect')
github openstreetmap / iD / modules / ui / background.js View on Github external
function clickSetSource(d) {
            if (d.id === 'custom' && !d.template()) {
                return editCustom();
            }

            d3_event.preventDefault();
            previous = context.background().baseLayerSource();
            context.background().baseLayerSource(d);
            selectLayer();
            document.activeElement.blur();
        }