question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

D'n'd Element Blocks MouseMove Event on It.

See original GitHub issue

I have 4 blocks above d’n’d element. When I do “mousedown” event to any one of this blocks turning off dragging I want to do some “mousemove” event for making connecting line from this element and etc.

I’ve alredy read the similar issue. But unfortunately I don’t understand how to let pass over “mousemove” event above d’n’d element.

Also I know that drag event forbid “mousemove” by default.

Who knows how does it work?

I’ll be glad for any information.

constructor(props: ElementProps & DiagramInjectStore) {
    super(props);

    this.handleFlowCursorSnapping = this.handleFlowCursorSnapping.bind(this) as (event: MouseEvent) => void;
    this.handleFlowCursorFinalSnapping = this.handleFlowCursorFinalSnapping.bind(this) as (event: MouseEvent) => void;
}

public render(): JSX.Element {
    const { coord, size } = this.element.properties;
    const { diagramId } = this.props;
    const { connectors } = this.element;

    return (
        <Select
            coord={ coord }
            size={ size }
            stage={ this.selectStage }
            canResizing={ false }

            onDragStart={ () => this.handleDragStart() }
            onDrag={ e => this.handleDrag(e) }
            onDragEnd={ e => this.handleDragEnd(e) }
        >
            <StyledGlyphElement>
                <Connectors
                    diagramId={ diagramId }
                    type={ ConnectorTypeKind.Element }
                    connectors={ connectors }
                    onMouseDown={ event => this.handleCreateFlow(event) }
                    onMouseOver={ event => this.handleBlur(event) }
                />
            </StyledGlyphElement>
        </Select>
    );
}

public componentDidMount(): void {
    document.body.addEventListener('mousemove', this.handleFlowCursorSnapping, false);
    document.body.addEventListener('mouseup', this.handleFlowCursorFinalSnapping, false);
}

public componentWillUnmount(): void {
    document.body.removeEventListener('mousemove', this.handleFlowCursorSnapping, false);
    document.body.removeEventListener('mouseup', this.handleFlowCursorFinalSnapping, false);
}

private handleFlowCursorSnapping(event: MouseEvent): void {
    document.body.addEventListener('mousemove', this.handleFlowCursorFinalSnapping, false);
}

private handleFlowCursorFinalSnapping(event: MouseEvent): void {
    document.body.removeEventListener('mousemove', this.handleFlowCursorSnapping, false);
}

doc

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
alekseoscommented, Oct 13, 2019

Sorry for delay.

  1. Eventually we solved our problem with help by changing structure of DOM selectors. Before that we dragged wrapped element instead of single element without wrapping. This implementation didn’t pass clicks and any mouse events to appropriate inner elements but did dragging events for wrapper.

  2. Before that we used another method. We blocked dragging from wrapper by using

handleMouseMove() {
   event.stopPropagation();
   event.preventDefault();

   ...code
}

I hope it will help.

10 окт. 2019 г., в 22:15, denys.bielkin notifications@github.com написал(а):  Yes, sir!

Can you please tell me - how? )

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

0reactions
denysbielkincommented, Oct 16, 2019

Thank you a lot 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Element: mousemove event - Web APIs | MDN
The mousemove event is fired at an element when a pointing device (usually a mouse) is moved while the cursor's hotspot is inside...
Read more >
Drag'n'Drop with mouse events - The Modern JavaScript Tutorial
So here we'll see how to implement Drag'n'Drop using mouse events. ... On mousedown – prepare the element for moving, if needed (maybe ......
Read more >
Mousemove delays firing mouseleave event - Stack Overflow
This CSS property, when set to "none" allows elements to not receive hover/click events, instead the event will occur on anything behind it....
Read more >
DnD mousemove events do not appear during drag. Why?
The original * dragstart event will be provided in the local event variable. * - dnd-moved Callback that is invoked when the element...
Read more >
7.7 Drag and drop — HTML5 - W3C
setData(internalDNDType, event.target.dataset.value); event. ... function dragEndHandler(event) { // remove the dragged element event.target.parentNode.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found