Skip to content

Instantly share code, notes, and snippets.

@ederchrono
Created May 15, 2019 06:44
Show Gist options
  • Save ederchrono/9e0316b3c8bbbe9243bcdb2cd77973ab to your computer and use it in GitHub Desktop.
Save ederchrono/9e0316b3c8bbbe9243bcdb2cd77973ab to your computer and use it in GitHub Desktop.
// inside the vue instance data
dragging: false,
cursorStartX: 0,
cursorCurrentX: 0
// after data
methods: {
startDrag(e) {
this.dragging = true
this.cursorStartX = getCursorX(e)
this.cursorCurrentX = this.cursorStartX
},
drag(e) {
if(!this.dragging) {
// avoid updating if not dragging
return
}
this.cursorCurrentX = getCursorX(e)
},
stopDrag(e) {
this.dragging = false
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment