[new feature] PullRefresh: add distance of slotProps (#3829)

This commit is contained in:
neverland
2019-07-11 19:24:22 +08:00
committed by GitHub
parent 0c7fc25d97
commit 907c9a3d03
5 changed files with 86 additions and 29 deletions
@@ -48,6 +48,30 @@ exports[`change head content when pulling down 5`] = `
</div>
`;
exports[`custom content by slots 1`] = `
<div class="van-pull-refresh">
<div class="van-pull-refresh__track" style="transition: 0ms; transform: translate3d(0,20px, 0);">
<div class="van-pull-refresh__head">pulling 20</div>
</div>
</div>
`;
exports[`custom content by slots 2`] = `
<div class="van-pull-refresh">
<div class="van-pull-refresh__track" style="transition: 0ms; transform: translate3d(0,75px, 0);">
<div class="van-pull-refresh__head">loosing 75</div>
</div>
</div>
`;
exports[`custom content by slots 3`] = `
<div class="van-pull-refresh">
<div class="van-pull-refresh__track" style="transition: 300ms; transform: translate3d(0,50px, 0);">
<div class="van-pull-refresh__head">loading 50</div>
</div>
</div>
`;
exports[`not in page top 1`] = `
<div class="van-pull-refresh">
<div class="van-pull-refresh__track" style="transition: 0ms;">
+31
View File
@@ -42,6 +42,37 @@ test('change head content when pulling down', async () => {
expect(wrapper).toMatchSnapshot();
});
test('custom content by slots', async () => {
const wrapper = mount(PullRefresh, {
scopedSlots: {
pulling({ distance }) {
return `pulling ${distance}`;
},
loosing({ distance }) {
return `loosing ${distance}`;
},
loading({ distance }) {
return `loading ${distance}`;
}
}
});
const track = wrapper.find('.van-pull-refresh__track');
// pulling
trigger(track, 'touchstart', 0, 0);
trigger(track, 'touchmove', 0, 20);
expect(wrapper).toMatchSnapshot();
// loosing
trigger(track, 'touchmove', 0, 100);
expect(wrapper).toMatchSnapshot();
// loading
trigger(track, 'touchend', 0, 100);
expect(wrapper).toMatchSnapshot();
});
test('pull a short distance', () => {
const wrapper = mount(PullRefresh, {
propsData: {