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

enable initial scroll #42

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

enable initial scroll #42

wants to merge 6 commits into from

Conversation

henrysha
Copy link

Per my feature request #41
I have created a fork and allowed initial scroll position through two props initialScrollLeft and initialScrollTop

Copy link
Owner

@okonet okonet left a 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.

Copy link
Owner

@okonet okonet left a 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",
Copy link
Owner

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 Show resolved Hide resolved
};

static childContextTypes = {
registerPane: PropTypes.func,
unregisterPane: PropTypes.func
}
};
Copy link
Owner

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

src/ScrollSync.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@henrysha henrysha requested a review from okonet August 14, 2020 09:41
@henrysha
Copy link
Author

@okonet should I get rid of yarn.lock and package-lock.json from the PR?

@okonet
Copy link
Owner

okonet commented Aug 14, 2020

You should not touch files that aren't related to the PR I'd suggest.

@henrysha
Copy link
Author

@okonet removed those files from PR

src/ScrollSync.js Outdated Show resolved Hide resolved
src/ScrollSync.js Outdated Show resolved Hide resolved
src/ScrollSync.js Outdated Show resolved Hide resolved
src/ScrollSync.js Outdated Show resolved Hide resolved
src/ScrollSync.js Outdated Show resolved Hide resolved
src/ScrollSync.js Outdated Show resolved Hide resolved
src/ScrollSync.js Outdated Show resolved Hide resolved
src/ScrollSync.js Outdated Show resolved Hide resolved
src/ScrollSync.js Outdated Show resolved Hide resolved
src/ScrollSync.js Outdated Show resolved Hide resolved
The semicolons came from prettier....
src/ScrollSync.js Outdated Show resolved Hide resolved
src/ScrollSync.js Outdated Show resolved Hide resolved
@okonet
Copy link
Owner

okonet commented Aug 14, 2020

Build is still failing, though:

12:00:28 PM:   134:36  error  Assignment to property of function parameter 'pane'  no-param-reassign
12:00:28 PM:   136:12  error  Assignment to property of function parameter 'pane'  no-param-reassign
12:00:28 PM:   141:36  error  Assignment to property of function parameter 'pane'  no-param-reassign
12:00:28 PM:   143:12  error  Assignment to property of function parameter 'pane'  no-param-reassign

@henrysha
Copy link
Author

@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
Copy link
Owner

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.

src/ScrollSync.js Show resolved Hide resolved
}
if (!this.state.initialized) this.state.initialized = true
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants