-
Notifications
You must be signed in to change notification settings - Fork 45
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
Remove ReactFauxDOM dependency for React usage and create npm module for React helper component #38
base: master
Are you sure you want to change the base?
Conversation
lib/index.js
Outdated
@@ -79,8 +116,7 @@ export default class HyperList { | |||
return | |||
} | |||
|
|||
const diff = lastRepaint ? scrollTop - lastRepaint : 0 | |||
if (!lastRepaint || diff < 0 || diff > this._averageHeight) { | |||
if (!lastRepaint || Math.abs(scrollTop - lastRepaint) > this._averageHeight) { |
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.
const diff = lastRepaint ? scrollTop - lastRepaint : 0
if (!lastRepaint || diff < 0 || diff > this._averageHeight) {
is correct
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.
Taken from 6ef597a7af3970f892f8457d5ac5292fdabc1589, but yes, it shouldn't be in the commit
@@ -101,7 +137,7 @@ export default class HyperList { | |||
refresh (element, userProvidedConfig) { | |||
Object.assign(this._config, defaultConfig, userProvidedConfig) | |||
|
|||
if (!element || element.nodeType !== 1) { | |||
if (!element || (typeof element.render !== 'function' && element.nodeType !== 1)) { |
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.
Why typeof element.render !== 'function'
?
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 suppose any element of a VirtualDOM has a render
function, cf. Matt-Esch/virtual-dom
.gitignore
Outdated
@@ -1,3 +1,4 @@ | |||
node_modules | |||
coverage | |||
dist | |||
package-lock.json |
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.
package-lock
should be commited
wdyt @tbranyen ? |
Looks good to me. I think I may have just caused a conflict by merging. Can we get this rebased to master and I'll give it a whirl in my app! |
@tbranyen I've worked a bit more on this and rebase will come in a couple of days ;) |
Sorry, I'll won't be able to complete this PR, I tried last week without any luck, so I made my own in React way, sorry 😔 I deprecated my repo thcolin/hyperlist-react, but anyone who want to start from where I was can fork it of course ! I tried to
Sorry for any false hope 😔 |
@thcolin I'm going to reopen this since it's interesting work and maybe someone else can pick it up. It's open source after-all. |
Hi !
My friend @soyuka told me about your library for my current React project, and he show me your ongoing pull request to improve React support without interfering too much with current implementation (Some initial work on React support #8).
So I work a bit on it and here's my suggestion :
inspectElement
andtransformElement
functions and make them configurable (as well asmergeStyle
)HyperList
will use its own methods (HyperList.inspectElement
,HyperList.transformElement
,HyperList.mergeStyle
) which expect aDOM
element as first argsinspectElement
,transformElement
andmergeStyle
because ofVirtual DOM
usageThis solution should allow you to support various not DOM-friendly frameworks in the long term.
If you're okay with my changes, I'll make another commit to remove
react-example.html
andreact
specific dev-dependecies and then create ahyperlist-react
npm module to bundleHyperListReact
React component and usage documentation. It would be helpful to have a link to futurhyperlist-react
repo onREADME
project too.HyperListReact
component would look like this :With same usage as #8 (see
examples/react-example.html
for full example) :