-
Notifications
You must be signed in to change notification settings - Fork 80
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
create scroll listener on mount instead of exported singleton #688
Conversation
this creates a new instance which probably creates a new listener per instance of the resizer. one possibility that I know react-waypoint uses is creates an event listener on the parent's dom node so that any sibling checks the parent for a listener before creating its own. |
Current coverage is 91.28% (diff: 100%)@@ master #688 diff @@
==========================================
Files 158 157 -1
Lines 2662 2662
Methods 264 264
Messages 0 0
Branches 734 734
==========================================
Hits 2430 2430
Misses 221 221
Partials 11 11
|
hm, generally there are at most a few resizing elements, right? Seems ok to me. Would be cool to implement the deduping logic you're talking about tho |
import _ from 'lodash'; | ||
import React from 'react'; | ||
import { common } from '../../util/generic-tests'; | ||
import { mount } from 'enzyme'; | ||
import Resizer from './Resizer'; | ||
import { elementResizeDetector } from './Resizer.util'; |
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.
wasn't there some reason we had to do this in the first place @mute ?
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.
We only pulled this out to a util
to maintain the singleton while making testing a little easier.
If we're okay with it not being a singleton, we don't need it anymore.
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.
Yeah, I don't think this should cause issues.
the existing module exports an instance of
element-resize-detector
which tries to bind event listeners ondocument.body
which may not be available at instantiation.PR Checklist
common
at minimum)semver-
labels[ ] One core team UX approval