Auto scroll not working when you are dragging a widget and at bottom or top of the screen.
https://github.com/gridstack/gridstack.js/assets/106658141/322edf99-55a6-4937-bdd4-51ee4883b05d
Subject: Auto scroll not working when you are dragging a widget and at bottom or top of the screen. Pre-requisite: Make the height of one of the items inside the grid bigger than the actual grid then drag an item from the outside of the grid to place it at the bottom, the screen does not scroll automatically.
Expected Behavior: Screen should scroll to the bottom of the screen https://github.com/gridstack/gridstack.js/assets/106658141/9baf629f-0cd6-48a5-bbf0-d25cbd3116c9
likely dup or at leasf related to #2032 and #2074
Boyce Dach said: I am using this method to solve the problem for the time being.
let startElPos = 0
myGridStack.on('dragstart', (event, el) => {
startElPos = el.getBoundingClientRect().top
})
myGridStack.on('drag', (event, el) => {
let currentElPos = el.getBoundingClientRect().top
let top = el.offsetTop * 2
/* if (currentElPos > startElPos) {
top = el.offsetTop * 2
} else if (currentElPos < startElPos) {
top = -(el.offsetTop * 2)
}*/
// Scroll up
if (currentElPos < startElPos) {
top = -(el.offsetTop * 2)
}
// document.querySelector(`.${props.parentCls}`).scrollTop = top
document.querySelector(`.${props.parentCls}`).scrollTo({
top,
behavior: 'smooth',
})
})
Is there any fix for this? @adumesny @tamilselvan-stratforge
not unless someone wants to sponsor this.
@adumesny shouldn't rect be compared with scrollElement also? https://github.com/gridstack/gridstack.js/blob/44b5a72a35c72acb22626a642b6a6075bca32d51/src/utils.ts#L390
likely fixed by #3251 . closing.