-
Notifications
You must be signed in to change notification settings - Fork 34
Enable scrolling of <draggable> container while dragging an element #134
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
Comments
no. It use HTML Drag and Drop API. Their behavior is same. |
Why did it work in the previous version, but it doesn't work in this one? |
do you mean he-tree-vue? It does not use HTML Drag and Drop API. |
I've implemented this, see example: <template>
<Draggable />
</template>
<script>
import '@he-tree/vue/style/default.css';
import { Draggable } from '@he-tree/vue';
export default {
data() {
return {
stopDragScrollY: true
}
},
computed: {
isVerticalMaxed() {
return window.innerHeight + window.scrollY >= document.body.offsetHeight;
}
},
mounted() {
window.addEventListener('drag', this.handleDrag);
},
unmounted() {
window.removeEventListener('drag', this.handleDrag);
},
methods: {
handleDrag(event) {
this.stopDragScrollY = true;
if (event.clientY < 150) {
this.stopDragScrollY = false;
this.handleScroll(-1); // scroll up
}
if (event.clientY > document.documentElement.clientHeight - 150 && !this.isVerticalMaxed) {
this.stopDragScrollY = false;
this.handleScroll(1); // scroll down
}
},
handleScroll(stepY) {
const scrollY = document.documentElement.scrollTop || document.body.scrollTop;
window.scrollTo(0, scrollY + stepY);
// continue scrolling until vertical direction is maxed using requestAnimationFrame
if (!this.stopDragScrollY) {
requestAnimationFrame(() => this.handleScroll(stepY));
}
},
},
}
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is not possible to scroll the container with the mouse while dragging an element with the mouse. Is there any way to enable this?
The text was updated successfully, but these errors were encountered: