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当页面有滚动条时定位不准确,采用relative+absoluete定位体系,支持列表多个元素hover效果 #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fanerge
Copy link

@fanerge fanerge commented Oct 17, 2018

进行优化一下:
fix当页面有滚动条时定位不准确,
采用relative+absoluete定位体系,
支持列表多个元素hover效果

@cht8687
Copy link
Owner

cht8687 commented Oct 19, 2018

@fanerge Thank for the contribution. I will review this change soon.

@cht8687
Copy link
Owner

cht8687 commented Oct 28, 2018

@shineli1984

What do you think about this change?

@@ -90,7 +95,7 @@ class ReactHover extends Component {
if (isNaN(shiftY)) {
shiftY = 0
}
updatedStyles = { ...hoverComponentStyle, top: cursorY + shiftY, left: cursorX + shiftX }
updatedStyles = { ...hoverComponentStyle, top: cursorY + shiftY - domPos.y, left: cursorX + shiftX - domPos.x }

Choose a reason for hiding this comment

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

According to https://caniuse.com/#search=getBoundingClientRect, the return value for getBoundingClientRect lacks x and y for ie and edge, we can use left and top to cover these 2 browsers.

src/ReactHover.js Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants