feat: Sticky/Picker support vw unit (#6816)
This commit is contained in:
@@ -56,7 +56,7 @@ export default {
|
||||
|
||||
| Attribute | Description | Type | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| offset-top `v2.8.7` | Offset top, supports `px` ans `rem` unit, default `px` | _number \| string_ | `0` |
|
||||
| offset-top `v2.8.7` | Offset top, supports `px` `vw` `rem` unit, default `px` | _number \| string_ | `0` |
|
||||
| z-index | z-index when sticky | _number \| string_ | `99` |
|
||||
| container | Container DOM | _Element_ | - |
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ export default {
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| --- | --- | --- | --- |
|
||||
| offset-top `v2.8.7` | 吸顶时与顶部的距离,支持 `px` 和 `rem` 单位,默认 `px` | _number \| string_ | `0` |
|
||||
| offset-top `v2.8.7` | 吸顶时与顶部的距离,支持 `px` `vw` `rem` 单位,默认 `px` | _number \| string_ | `0` |
|
||||
| z-index | 吸顶时的 z-index | _number \| string_ | `99` |
|
||||
| container | 容器对应的 HTML 节点 | _Element_ | - |
|
||||
|
||||
|
||||
@@ -36,6 +36,14 @@ exports[`offset-top with rem unit 1`] = `
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`offset-top with vw unit 1`] = `
|
||||
<div style="height: 10px;">
|
||||
<div class="van-sticky van-sticky--fixed" style="top: 30px;">
|
||||
Content
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`sticky to top 1`] = `
|
||||
<div style="height: 10px;">
|
||||
<div class="van-sticky">
|
||||
|
||||
@@ -63,6 +63,22 @@ test('offset-top with rem unit', () => {
|
||||
window.getComputedStyle = originGetComputedStyle;
|
||||
});
|
||||
|
||||
test('offset-top with vw unit', () => {
|
||||
window.innerWidth = 300;
|
||||
|
||||
const wrapper = mount({
|
||||
template: `
|
||||
<van-sticky style="height: 10px;" offset-top="10vw">
|
||||
Content
|
||||
</van-sticky>
|
||||
`,
|
||||
});
|
||||
|
||||
mockScrollTop(100);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
mockScrollTop(0);
|
||||
});
|
||||
|
||||
test('should not trigger scroll event when hidden', () => {
|
||||
const scroll = jest.fn();
|
||||
mount({
|
||||
|
||||
Reference in New Issue
Block a user