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

feat(Popup): Provide option to handle vertical offset #2444

Closed
wants to merge 3 commits into from

Conversation

bharatzvm
Copy link
Contributor

@bharatzvm bharatzvm commented Jan 18, 2018

Breaking Change

Popup now supports vertical offset alongside horizontal offset, in process offset prop
had to be renamed explicitly to mention the axis.

Before

  <Popup offset={1000} />

After

  <Popup horizontalOffset={1000} />

@codecov-io
Copy link

codecov-io commented Jan 18, 2018

Codecov Report

Merging #2444 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2444      +/-   ##
==========================================
+ Coverage   99.74%   99.74%   +<.01%     
==========================================
  Files         154      154              
  Lines        2699     2700       +1     
==========================================
+ Hits         2692     2693       +1     
  Misses          7        7
Impacted Files Coverage Δ
src/modules/Popup/Popup.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 a740b36...f88dbee. Read the comment docs.

@levithomason
Copy link
Member

Whoops, appears we also have #2450, where I've left some updated comments. I'll let you two decide which PR to keep around. If you should choose to update your PR, please see the comments I left there.

@bharatzvm
Copy link
Contributor Author

@levithomason I have made some updates according to the discussions in #2450 and #1146, waiting for your opinion. Sorry for delay in response, I was travelling.


applyVeriticalOffset = ({ top, bottom }, offset) => {
if (_.isNumber(top)) return { bottom, top: top + offset }
return { top, bottom: bottom + offset }
Copy link
Contributor

Choose a reason for hiding this comment

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

@bharatzvm, theverticalOffset calculation should be different based on if the popup is located above or below the trigger. Are you sure this logic will not work as expected when the popup is below the trigger?

Copy link
Contributor Author

@bharatzvm bharatzvm Jan 30, 2018

Choose a reason for hiding this comment

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

@adam-26 I followed the notion of moving the popup outwards of the screen through the centre of the screen from the explicitly positioned direction whichever it is. It was also one of the reason why I had to add the offset.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adam-26 My bad again, I was wrong thanks for spotting it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adam-26 I think the logic works fine irrespective of the positioning because if it can't place the popup in the view port it tries all other positions until it find ones in the viewport if it cant, it falls back to the position user specified position. I will be updating the pr to fix these reviews

return style
applyHorizontalOffset = ({ right, left }, offset) => {
if (_.isNumber(right)) return { left, right: right + offset }
return { right, left: left + offset }
Copy link
Contributor

Choose a reason for hiding this comment

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

@bharatzvm, the original code subtracts the horizontalOffset value from the left/right value, you are adding the offset. Have you made a code change somewhere else that inverts the logic?

Copy link
Contributor Author

@bharatzvm bharatzvm Jan 30, 2018

Choose a reason for hiding this comment

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

@adam-26, Consider my previous comment here too(But my bad, I didn't realise this change while creating the pr)

bp added 3 commits February 1, 2018 15:17
      Updated Popup-tests
      Updated Examples usage examples
      Updated Popup typing
@levithomason
Copy link
Member

@bharatzvm PR #2450 has been updated and merged. I will close this one. Thank you for working on this and for collaborating with @adam-26.

@bharatzvm bharatzvm deleted the changes-bp branch March 2, 2018 12:48
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.

4 participants