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

Feature/back top #40

Merged
merged 20 commits into from
May 9, 2019
Merged

Feature/back top #40

merged 20 commits into from
May 9, 2019

Conversation

MuYunyun
Copy link
Member

@MuYunyun MuYunyun commented May 5, 2019

  • 增加 backTop 组件

测试用例中不识别 window.scrollTo 属性,
image

jest.config.js 增加如下配置

{
  setupFiles: ['<rootDir>/setup.js']
}

setup.js 如下:

window.alert = msg => {
  console.log(msg)
}
window.matchMedia = () => ({})
window.scrollTo = () => {}

console.log(msg)
}
window.matchMedia = () => ({})
window.scrollTo = () => {}
Copy link
Contributor

Choose a reason for hiding this comment

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

是否需要 mock 回去

Copy link
Contributor

Choose a reason for hiding this comment

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

同问

Copy link
Member Author

Choose a reason for hiding this comment

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

再 mock 回去是把 window.scrollTo = null 嘛, 这样子没什么必要吧

Copy link
Contributor

Choose a reason for hiding this comment

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

不是啊 是这样子的
const a = window.scrollTo
widow.scrollTo = () => {}
window.scrollTo = a

const [show, setShow] = useState(false)

const scrollLogic = () => {
if (window.scrollY >= 400) {
Copy link
Contributor

Choose a reason for hiding this comment

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

居然偷偷hard code(没使用visibilityHeight这个props)

Copy link
Member Author

Choose a reason for hiding this comment

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

hard code 翻译成硬核编程?

})}
onClick={backTopFn}
>
{children ? children : <Icon type="totop" color="#fff" />}
Copy link
Contributor

Choose a reason for hiding this comment

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

children ||

Copy link
Member Author

Choose a reason for hiding this comment

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

d=====( ̄▽ ̄*)b厉害

@anyexinglu anyexinglu merged commit f8a163e into ming-cult:master May 9, 2019
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