feat(Sticky): offset-top support rem unit (#6556)

This commit is contained in:
neverland
2020-06-17 18:10:07 +08:00
committed by GitHub
parent fd388d0475
commit f2543b5dfa
5 changed files with 49 additions and 17 deletions
@@ -28,6 +28,14 @@ exports[`offset-top prop 1`] = `
</div>
`;
exports[`offset-top with rem unit 1`] = `
<div style="height: 10px;">
<div class="van-sticky van-sticky--fixed" style="top: 16px;">
Content
</div>
</div>
`;
exports[`sticky to top 1`] = `
<div style="height: 10px;">
<div class="van-sticky">
+20
View File
@@ -43,6 +43,26 @@ test('offset-top prop', () => {
mockScrollTop(0);
});
test('offset-top with rem unit', () => {
const originGetComputedStyle = window.getComputedStyle;
window.getComputedStyle = () => ({ fontSize: '16px' });
const wrapper = mount({
template: `
<van-sticky style="height: 10px;" offset-top="1rem">
Content
</van-sticky>
`,
});
mockScrollTop(100);
expect(wrapper).toMatchSnapshot();
mockScrollTop(0);
window.getComputedStyle = originGetComputedStyle;
});
test('should not trigger scroll event when hidden', () => {
const scroll = jest.fn();
mount({