-
Notifications
You must be signed in to change notification settings - Fork 50
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
On scroll element also moves up and down?So can this feature not be used in a long page? #11
Comments
By element I mean draggable element |
Please provide explanation, example and screenshot |
See my draggable component gets attached to screen and remains there only as I scroll through the page ...for eg if I have element at centre of screen then it remains there only ..it doesn't get attached to page |
Currently you can't. |
The problem is actual for me too @ashutosh1807 Are you fix this for you? Or what the alternative of yours solution? |
I was about to open this very issue, when I found that someone else ran into the same problem. Source of this issueThe issue is with line 163 in Recommendation
|
FYI, I'm using the directive like
|
Or better;
|
Hi guys, I already started to work about the solution, 'absolute' positioning is problematic with bounding-rectangle feature. |
When can solve this issues? |
it will take a while |
@IsraelZablianov I congratulate you on the pack you created. Please fix this function. |
I've ended with a solution without modifying the directive, assuming multiple boxes to drag, bounding to a container. 1) Set each box a class
onDragStart: function(positionDiff, absolutePosition, event) {
let box = event && event.target && event.target.closest('[draggable-state]')
if (box) {
// Get the model
const id = box.id
let found = this.boxes.find(b => b.id === id)
if (found && !found.firstTouched) {
// On the first touch, the directive's initialPosition, startDragPosition, currentDragPosition needs to be set wrt to the viewport
const container = this.$refs.container.getBoundingClientRect()
const top = absolutePosition.top + container.top
const left = absolutePosition.left + container.left
box.style.top = top + 'px'
box.style.left = left + 'px'
let draggableState = JSON.parse(box.getAttribute('draggable-state')) || {}
draggableState.initialPosition = { left, top }
draggableState.startDragPosition = { left, top }
draggableState.currentDragPosition = { left, top }
box.setAttribute('draggable-state', JSON.stringify(draggableState))
// Record in model that the box has been touched
found.firstTouched = true
} else {
box.style.top = absolutePosition.top + 'px'
box.style.left = absolutePosition.left + 'px'
}
// Remove the class
box.classList.remove('drag-box')
}
}
onDragEnd: function(positionDiff, absolutePosition, event) {
let box = event && event.target && event.target.closest('[draggable-state]')
if (box) {
const container = this.$refs.container.getBoundingClientRect()
const top = absolutePosition.top - container.top
const left = absolutePosition.left - container.left
box.style.top = top + 'px'
box.style.left = left + 'px'
// Add the class again
box.classList.add('drag-box')
}
} |
A remaining problem is if the page scrolled, the directive's initialPosition, startDragPosition, currentDragPosition are not updated and the first touch of the box will suddenly move the box to somewhere else. But after the first touch, everything is fine again. |
No description provided.
The text was updated successfully, but these errors were encountered: