gridstack.js icon indicating copy to clipboard operation
gridstack.js copied to clipboard

Auto scroll not working when you are dragging a widget and at bottom or top of the screen.

Open tamilselvan-stratforge opened this issue 2 years ago • 6 comments

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

tamilselvan-stratforge avatar Dec 18 '23 15:12 tamilselvan-stratforge

likely dup or at leasf related to #2032 and #2074

adumesny avatar Dec 22 '23 17:12 adumesny

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',
      })
    })

adumesny avatar Jan 22 '24 16:01 adumesny

Is there any fix for this? @adumesny @tamilselvan-stratforge

masum-mollik-rocketml avatar Apr 30 '24 03:04 masum-mollik-rocketml

not unless someone wants to sponsor this.

adumesny avatar Apr 30 '24 14:04 adumesny

@adumesny shouldn't rect be compared with scrollElement also? https://github.com/gridstack/gridstack.js/blob/44b5a72a35c72acb22626a642b6a6075bca32d51/src/utils.ts#L390

masum-mollik-rocketml avatar May 01 '24 03:05 masum-mollik-rocketml

likely fixed by #3251 . closing.

adumesny avatar Mar 31 '26 01:03 adumesny