Skip to content
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

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

Open
tamilselvan-stratforge opened this issue Dec 18, 2023 · 5 comments
Labels

Comments

@tamilselvan-stratforge
Copy link

bcda637f-5b79-49cd-9544-8e9d3fd2f567.mp4

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

@adumesny
Copy link
Member

adumesny commented Dec 22, 2023

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

@adumesny
Copy link
Member

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

@masum-mollik-rocketml
Copy link

masum-mollik-rocketml commented Apr 30, 2024

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

@adumesny
Copy link
Member

not unless someone wants to sponsor this.

@masum-mollik-rocketml
Copy link

@adumesny shouldn't rect be compared with scrollElement also?

if (rect.top < 0 ||

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants