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

fix(Visibility): fix behaviour of reverse calls #2088

Merged
merged 3 commits into from
Sep 21, 2017

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented Sep 19, 2017

I'm working on #2070, but it can't be finished without changes there.

We have wrong behaviour for *reverse callbacks and it's easy to show, see GIFs. We fire them always, but in fact they should be called in the oppositite condition.

// topPassed
if(calculations.topPassed) module.execute(callback, callbackName);

// topPassedReverse
if(!calculations.topPassed) module.execute(callback, callbackName);

SUI

Click to expand

SUIR

Click to expand

@codecov-io
Copy link

codecov-io commented Sep 19, 2017

Codecov Report

Merging #2088 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2088      +/-   ##
==========================================
- Coverage   99.76%   99.76%   -0.01%     
==========================================
  Files         149      149              
  Lines        2601     2598       -3     
==========================================
- Hits         2595     2592       -3     
  Misses          6        6
Impacted Files Coverage Δ
src/behaviors/Visibility/Visibility.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65ce852...b6114d6. Read the comment docs.

@layershifter layershifter changed the title fix(Visibility): fire on window resize, fix behaviour of reverse calls fix(Visibility): fix behaviour of reverse calls Sep 20, 2017
Copy link
Member Author

@layershifter layershifter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready for review. Now the component's behaviour matches to SUI. I've also shipped some cleanups for tests there.

}

firedCallbacks = []
occurredCallbacks = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the original name here is more appropriate, firedCallbacks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored 👍

}

componentDidMount() {
if (!isBrowser) return

const { context, fireOnMount } = this.props

context.addEventListener('scroll', this.handleScroll)
if (fireOnMount) this.handleUpdate()
context.addEventListener('scroll', this.handleUpdate)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: suggest keeping handleScroll for the scroll handler. It makes it clear when/why it is called.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comes from #2091, this handler will also handle resize event

@@ -26,67 +26,72 @@ const mockScroll = (top, bottom) => {
}
}

window.dispatchEvent(new Event('scroll'))
domEvent.scroll(window)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

Copy link
Member

@levithomason levithomason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to merge after the small naming updates.

@layershifter layershifter merged commit e2fc8f5 into master Sep 21, 2017
@layershifter layershifter deleted the fix/visibility-events branch September 21, 2017 17:47
@layershifter
Copy link
Member Author

@levithomason I've restored naming, as you approved changes in this PR, I merged it 💥

@levithomason
Copy link
Member

Released in semantic-ui-react@0.74.0

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

Successfully merging this pull request may close these issues.

3 participants