moveable icon indicating copy to clipboard operation
moveable copied to clipboard

Scrollable: Continuous Scrolling

Open jtr-dev opened this issue 2 years ago • 2 comments

Environments

  • Framework name: ngx-moveable
  • Framework version: 0.26.8
  • Moveable Component version: 0.26.8
  • Testable Address(optional):

Description

Is there a way to implement scroll so that the scroll event can continuously fire. Exposing a scrollStart/scrollEnd event I could create a while loop. Currently the scroll event only fires during drag.

jtr-dev avatar Jun 21 '22 23:06 jtr-dev

@jtr-dev

See this example: https://daybrush.com/moveable/storybook2/?path=/story/support-scroll--tree-shaking-template

daybrush avatar Jun 26 '22 15:06 daybrush

Currently it only triggers on drag move.

Pseudo Example:

class MyComponent {
  moveable: any;
  timer: number | null;

  onMouseMove() {
    if (this.timer) {
      clearInterval(this.timer);
      this.timer = null;
    }
  }
  onScroll(event) {
    const { scrollContainer, direction } = event;
    scrollContainer.scrollBy(direction[0], direction[1]);
    if (this.timer === null) {
      if (this.moveable.isDragging()) {
        this.timer = window.setInterval(() => {
          console.log('contine to scroll');
          this.onScroll(event); // old event state 
        }, 200)
      }
    }
  }
}

Initally tried creating a timer myself with the proper events. However there seems to be code to allow for it to scroll while the mouse is not moving.

@scena/dragscroll timer has similar timer logic to what I was doing.

I ran into issues last week trying to put a sandbox demo together but I can work on this a bit more if further explanation would help.

Much appreciated, Thanks.

jtr-dev avatar Jun 27 '22 15:06 jtr-dev