-
Notifications
You must be signed in to change notification settings - Fork 62
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
enable initial scroll #42
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! For start, let's follow the code style of this repository so I can review your changes and the build passes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the code style of this repo. It's done automatically on pre-commit.
package.json
Outdated
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "react-scroll-sync", | |||
"version": "0.0.0-development", | |||
"version": "0.0.1-development", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not change the version. It's done automatically.
src/ScrollSync.js
Outdated
}; | ||
|
||
static childContextTypes = { | ||
registerPane: PropTypes.func, | ||
unregisterPane: PropTypes.func | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code style isn't followed
@okonet should I get rid of yarn.lock and package-lock.json from the PR? |
You should not touch files that aren't related to the PR I'd suggest. |
@okonet removed those files from PR |
The semicolons came from prettier....
them semis
Build is still failing, though:
|
@okonet hey, sorry for the late fix. I have just found out that this has yet to be merged, and I added a eslint ignore to ignore those errors..... Not sure why those errors didn't appear before though. |
|
||
/* Calculate the actual pane height */ | ||
const paneHeight = pane.scrollHeight - clientHeight | ||
const paneWidth = pane.scrollWidth - clientWidth | ||
/* Adjust the scrollTop position of it accordingly */ | ||
if (vertical && scrollTopOffset > 0) { | ||
pane.scrollTop = proportional ? (paneHeight * scrollTop) / scrollTopOffset : scrollTop // eslint-disable-line | ||
if (!this.state.initialized) pane.scrollTop = initialScrollTop | ||
// eslint-disable-next-line curly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not disable this rule please and instead do what ESLint suggests.
} | ||
if (!this.state.initialized) this.state.initialized = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think React state should not be mutated like this. Either use setState
or don't use state
for it. Maybe that's there the ESLint error comes from?
Per my feature request #41
I have created a fork and allowed initial scroll position through two props
initialScrollLeft
andinitialScrollTop