question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: scrollTo

See original GitHub issue

Any chance you will add scrollTo functionality? Or there is more appropriate library for this?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
stereoboostercommented, Jun 3, 2017

Huh, this is something new. Haven’t seen Element.scrollIntoView().

I’m not convinced we really get anything out of making them the same lib

Well they share some functionality - measuring position of elements.

But I have no strong preference. Will try suggested solutions. Thanks a lot

UPD:

For future googlers there is Element.scrollIntoView() and Element.scrollIntoViewIfNeeded() see caniuse

UPD 2:

Solution looks like this, inspired by http://blog.vjeux.com/2013/javascript/scroll-position-with-react.html

import smoothscrollPolyfill from 'smoothscroll-polyfill';
smoothscrollPolyfill.polyfill();

class MyComponent extends Component {
  componentDidUpdate() {
    if (this.props.active) {
      this.cardContainer.scrollIntoView({behavior: 'smooth'});
    }
  }

  render() {
    return (
      <div ref={ div => { this.cardContainer = div } }>{...}</div>)
  }
}
0reactions
lencionicommented, May 31, 2017

Yep, if you need smooth scrolling, I’d go with Element.scrollIntoView() and a polyfill. I know some folks at Airbnb have set that up and I haven’t heard of any issues with it.

https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView

airbnb-browser-shims brings in smoothscroll-polyfill

I’m not convinced we really get anything out of making them the same lib. Right now there are clearly separated components, managed by two different teams. This seems like a good system to me, because they’re working on making the best scroll component, and we’re working on making the best waypoint component.

👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature request: scrollTo with alignToTop - v6 - CodeMirror
In order to restore the user's scroll position when they re-open a document, we'd like to be able to scroll a stored line...
Read more >
[FEATURE REQUEST] ScrollTo specific index. #196 - GitHub
In my case, I want to use dynamic index everyTime so i cannot use scrollTo function because it takes static count. Is there...
Read more >
feature request for scroll to top : r/BoostForReddit
In portrait mode (the way basically all smartphones operate), pressing the Home icon in the bottom row scrolls to the top. I like...
Read more >
Feature request: Scroll to Top Only on Categories / Tags
One big request, a way to have the scroll to top appear only specific posts within specific categories or tags. Thanks in advance....
Read more >
Feature Request: Scroll To Me
Hello. This is what I hope is a pretty simple request, @zep. Currently if you click PLAY on any Pico-8 project included in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found