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

scroll when dragging #117

Open
KumailHussain opened this issue Aug 15, 2018 · 12 comments
Open

scroll when dragging #117

KumailHussain opened this issue Aug 15, 2018 · 12 comments

Comments

@KumailHussain
Copy link

If i have a large number of items the container can't scroll at own

@MNorgren
Copy link

Anyone have suggestions on how to do this? This would be very beneficial to me as well

@jarhys
Copy link

jarhys commented Oct 1, 2018

Set a timer function when dragging,
check if the dragged item is outside the container,
and scroll the container.

@jzahka
Copy link

jzahka commented Oct 15, 2018

You can try https://github.com/hollowdoor/dom_autoscroller
Worked for me for this exact issue.

@Supamiu
Copy link

Supamiu commented Oct 26, 2018

@jzahka Can you please provide a code example? Or did it just work out of the box?

@jzahka
Copy link

jzahka commented Oct 26, 2018

I more or less copied the example in the repo https://github.com/hollowdoor/dom_autoscroller#usage

import autoScroll from 'dom-autoscroller';
// ...

constructor(private element: ElementRef) {}
// ...
ngAfterViewInit() {
  autoScroll([
    this.element.nativeElement // element needs to be scrollable
  ], {
    margin: 50,
    maxSpeed: 20,
    autoScroll: function() {
      // only scroll when mouse is down
      // `this` does not refer to component here
      return this.down;
    }
  });
}

@GitHubish
Copy link

Do you have performance problems at home with ngx-dnd and dom_autoscroll? I made a kind of board like Trello (much lighter in terms of features), I added dom_autoscroll to scroll vertically and horizontally but the interface is very jerky. Do you have the same problem?

@jzahka
Copy link

jzahka commented Feb 22, 2019

@GitHubish I haven't had the jerky interface issue you describe.

@GitHubish
Copy link

I did a test project, the problem arises as soon as there are a certain number of elements displayed. In my case with an interface without CSS, without any other complexity / heaviness caused by other components, animations jerk with 250 elements.

@hijoncon
Copy link

@jzahka how do you destroy when leaving the component?

@marcio199226
Copy link

marcio199226 commented Jul 4, 2019

@jzahka @GitHubish
You should initialize autoScroll inside runOutsideAngular for better performance so all events catched up by listeners registered in autoScroll will not cause change detection to run

@Kartheek2016
Copy link

Hey @hijoncon
Did you find a solution or work around on how to destroy when leaving the component!?

@jzahka
Copy link

jzahka commented Jul 24, 2020

I believe you can use destroy() on the instance returned by the autoScroll() function.
https://github.com/hollowdoor/dom_autoscroller#destroyforcecleananimation

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

No branches or pull requests

10 participants