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 #1

Open
desandro opened this issue Mar 17, 2013 · 17 comments
Open

Scroll #1

desandro opened this issue Mar 17, 2013 · 17 comments

Comments

@desandro
Copy link
Owner

desandro commented Mar 17, 2013

When you drag an element close to the viewport's edge, it should scroll -- if enabled.

Add a πŸ‘ reaction to this issue if you would like to see this feature added. Do not add +1 comments β€” They will be deleted.

jQuery UI Draggable has some nice options for this: scroll, scrollSensitivity, and scrollSpeed.

A possible awkward scenario involves when you have multiple dragging elements, one of the is ready to trigger scroll, but then another is at an opposite edge. Ideally the scroll should only be triggered while keeping every dragging element in the viewport.

@woollsta
Copy link

I imagine you would have to do something very roughly like this.. just written in crappy-tuesday-morning-pseudo-code.

declare global object inScrollArea;

for each draggable item {
    on drag move {
        if this drag pos is in scroll boundary {
              -> insert into inScrollArea[this index] value 1;
              -> if this index is the only value in array {
                       -> do scrolly stuff;
                  }else {
                       -> kill scrolly stuff;
                  }
        } else {
              -> remove inScrollArea[index];
        }
    }
    on drag end {
        -> remove inScrollArea[index];
    }
}

Of course it's bound to be more complicated because all active dragging elements will be triggering the scrolly script, so could cause some jittering and general usability hell.

Some things to consider I guess would include:

  • would you need to accelerate speed the longer someone is in the scroll boundary?
  • would scrolling work if the body was set to overflow hidden?
  • if you had the draggable item in the bottom right corner, would it scroll diagonally if side scrolling was allowed?

I haven't seen the jQuery UI's implementation, but I imagine they've come up with some clever. After using this with your packery library I can see this being a useful addition.

Also great job on the lot, I'm using packery and isotope in a project and getting extra brownie points from the manager. Wohay!

@woollsta
Copy link

Also interesting observation: IE8 appears to scroll the body automatically when dragging past the browser edge.

@pistachiomatt
Copy link

Hate to be a bumper, but this would be a great feature.

@mbme
Copy link

mbme commented Nov 25, 2014

+1 for this feature

@st-daristodemo
Copy link

I agree, would be a great feature.

@lkrids
Copy link

lkrids commented Aug 5, 2015

+1

1 similar comment
@ctjhoa
Copy link

ctjhoa commented Aug 10, 2015

+1

@Nuru
Copy link

Nuru commented Sep 17, 2015

+1 need this right now

@EliotSlevin
Copy link

+1

1 similar comment
@wswoodruff
Copy link

+1

@zacol
Copy link

zacol commented Feb 11, 2016

+1

Any idea how to do that?

wswoodruff added a commit to BigRoomTechnologies/draggabilly that referenced this issue Jun 5, 2016
@sirgallifrey
Copy link

sirgallifrey commented Jul 19, 2016

I've made a fork from draggabilly that implements scrolling inside another element, autoscrolling and scalling (that I needed for a project). It's not perferct and it won't account for multiple dragging elements yet, but you guys can help me to improve :)

https://github.com/sirgallifrey/draggabilly-ps

@jrdn91
Copy link

jrdn91 commented Aug 16, 2016

Any progress on this? I'm about to have to build my own implementation of it for our project using packery with draggabilly

@chrisgrovers
Copy link

^^ Any update @Jordan4jc? I'm about to do the same

@jrdn91
Copy link

jrdn91 commented Sep 7, 2016

@chrisgrovers no, I haven't done anything with it yet, but I'll have to here soon.

Repository owner deleted a comment from wwhyte Jan 25, 2018
Repository owner deleted a comment from neronmoon Jan 25, 2018
Repository owner deleted a comment from davemeehan Jan 25, 2018
Repository owner deleted a comment from jim-at-miramontes Jan 26, 2018
Repository owner deleted a comment from tclarke104 Jan 26, 2018
Repository owner deleted a comment from hanlakewind Jan 26, 2018
Repository owner deleted a comment from tbrother Jan 26, 2018
Repository owner deleted a comment from dmitriylyner Jan 26, 2018
Repository owner deleted a comment from nufrifin Jan 26, 2018
@jim-at-miramontes
Copy link

Bump -- has there been, or is there likely to be, any progress on this? Just checking...

@DataTables
Copy link

If anyone else is interested in this, I've implemented as a couple of function calls to be called in dragStart (_startStopScroll) and dragEnd (_stopScroll).

Its TypeScript code and its offered as public domain - do as you will with it.

	private _pageYPosition: number;
	private _scrollTimer;

	private _startStopScroll(e: MouseEvent = null) {
		if (e) {
			this._pageYPosition = e.pageY;
		}

		if (this._pageYPosition > window.innerHeight + window.scrollY - 50) {
			if (! this._scrollTimer) {
				this._scrollTimer = setTimeout(() => {
					window.scrollBy(0, 5);

					this._pageYPosition += 5;
					this._scrollTimer = null;
					this._startStopScroll();
				}, 25);
			}
		}
		else if (this._pageYPosition < window.scrollY + 50) {
			if (! this._scrollTimer) {
				this._scrollTimer = setTimeout(() => {
					window.scrollBy(0, -5);

					this._pageYPosition -= 5;
					this._scrollTimer = null;
					this._startStopScroll();
				}, 25);
			}
		}
		else {
			if (this._scrollTimer) {
				clearTimeout(this._scrollTimer);
				this._scrollTimer = null;
			}
		}
	}

	private _stopScroll() {
		clearTimeout(this._scrollTimer);
		this._scrollTimer = null;
	}

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