Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: onDragEnd report wrong (0,0) offset when clicking element with preset position #164

Open
Andrioden opened this issue Jul 28, 2024 · 1 comment

Comments

@Andrioden
Copy link

Andrioden commented Jul 28, 2024

The problem is if the user clicks/taps the draggable object, it wrongly report as if it was moved to position 0,0, while infact it was left at its initial position.

My options

        dragOptions: function() {
            return {
                position: {
                    x: 7,
                    y: 0
                },
                onDragStart: this.dragStartEventHandler,
                onDragEnd: this.dragStopEventHandler,
                defaultClassDragging: "dragging",
                ignoreMultitouch: true // Should default to false, but the library has a bug https://github.com/PuruVJ/neodrag/issues/144
            }
        },

My stop handler

        dragStopEventHandler: async function(event) {
            console.log(event.currentNode.style.transform) // = translate3d(7px, 0px, 0px)
            console.log(event.offsetX, event.offsetY) // = 0,0
            // I would expect it to be 7,0
        },

Extra info

  • I also have a delegated click handler attached to a child of the draggable, this click event fire after the dragStop

Using

  • "@neodrag/vue": "2.0.4"
  • "@pnotify/core": "5.2.0"
@Andrioden
Copy link
Author

Andrioden commented Jul 28, 2024

Workaround

        dragStopEventHandler: async function(event) {
            if (event.currentNode.style.transform !== `translate3d(${event.offsetX}px, ${event.offsetY}px, 0px)`) {
                console.log("bug detected, abort")
                return
            }
            // ...
        },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant