Skip to content

Commit

Permalink
Print and remove noisy type
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound committed Dec 26, 2017
1 parent 6bf535f commit 0c54505
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions source/WindowScroller/WindowScroller.jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ describe('WindowScroller', () => {
describe('onResize', () => {
it('should trigger callback on init and when window resizes', () => {
const resizeFn = jest.fn();
render(getMarkup({ onResize: resizeFn }));
render(getMarkup({onResize: resizeFn}));

simulateWindowResize({height: 1000, width: 1024});

expect(resizeFn).toHaveBeenCalledTimes(1);
expect(resizeFn).lastCalledWith({ height: 1000, width: 1024, });
expect(resizeFn).lastCalledWith({height: 1000, width: 1024});
});

it('should update height when window resizes', () => {
Expand Down
7 changes: 3 additions & 4 deletions source/WindowScroller/WindowScroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ type State = {
*/
export const IS_SCROLLING_TIMEOUT = 150;

const getWindow = () =>
typeof window !== 'undefined' ? window : undefined;
const getWindow = () => (typeof window !== 'undefined' ? window : undefined);

export default class WindowScroller extends React.PureComponent<Props, State> {
static defaultProps = {
Expand Down Expand Up @@ -124,7 +123,7 @@ export default class WindowScroller extends React.PureComponent<Props, State> {
registerScrollListener(this, scrollElement);
}

window.addEventListener('resize', this._onResize, false);
window.addEventListener('resize', this._onResize, false);

this._isMounted = true;
}
Expand Down Expand Up @@ -168,7 +167,7 @@ export default class WindowScroller extends React.PureComponent<Props, State> {
});
}

_onChildScroll = ({scrollTop}: {scrollTop: number}) => {
_onChildScroll = ({scrollTop}) => {
if (this.state.scrollTop === scrollTop) {
return;
}
Expand Down
4 changes: 3 additions & 1 deletion source/WindowScroller/utils/onScroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ export function registerScrollListener(
component: WindowScroller,
element: Element,
) {
if (!mountedInstances.some(instance => instance.props.scrollElement === element)) {
if (
!mountedInstances.some(instance => instance.props.scrollElement === element)
) {
element.addEventListener('scroll', onScrollWindow);
}
mountedInstances.push(component);
Expand Down

0 comments on commit 0c54505

Please sign in to comment.