StreamMeDev / scroll-to

Smoothly scroll somewhere
ISC License
1 stars 0 forks source link

Add support for scrolling things other than `window` #6

Closed wesleytodd closed 7 years ago

wesleytodd commented 8 years ago

Something like this:

scrollTo({
  element: document.querySelector('.some-element'),
  x: 100
});
cwebley commented 8 years ago

Was just thinking about this too. Not extremely familiar with this, but it looks like a slightly different api:

window

// scroll to top left of page
window.scroll(0, 0)

element

// set element scroll position to top left:
ele.scrollLeft = 0;
ele.scrollTop = 0;

we could definitely handle the element case and default to window if element is undefined

wesleytodd commented 8 years ago

hmm, yeah seems like more work than I thought. I still think that the exposed api could be like I said above, but the implementation itself might have to change. I was originally thinking it would just be:

options.element = options.element || window;
// ...
options.element.scroll();
cwebley commented 8 years ago

Yeah that's what I was hoping too. Anyway, I can do this after I finish up some other work this week if you think we'll use element scrolling soon

wesleytodd commented 8 years ago

No rush, but it would be nice to use this in the chat's "scroll to bottom" button

wesleytodd commented 7 years ago

Closed in #7