-
Notifications
You must be signed in to change notification settings - Fork 12
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
Feature/back top #40
Conversation
console.log(msg) | ||
} | ||
window.matchMedia = () => ({}) | ||
window.scrollTo = () => {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是否需要 mock 回去
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同问
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
再 mock 回去是把 window.scrollTo = null 嘛, 这样子没什么必要吧
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
居然偷偷hard code(没使用visibilityHeight这个props)
There was a problem hiding this comment.
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" />} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
children ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d=====( ̄▽ ̄*)b厉害
测试用例中不识别 window.scrollTo 属性,
jest.config.js
增加如下配置setup.js 如下: