[improvement] PullRefresh: optimize loading

This commit is contained in:
陈嘉涵 2019-05-13 20:12:43 +08:00
parent 0c641f7d63
commit a6b429cf58
3 changed files with 14 additions and 18 deletions

View File

@ -150,11 +150,7 @@ export default sfc({
const Status = this.slots(status) || [ const Status = this.slots(status) || [
TEXT_STATUS.indexOf(status) !== -1 && <div class={bem('text')}>{text}</div>, TEXT_STATUS.indexOf(status) !== -1 && <div class={bem('text')}>{text}</div>,
status === 'loading' && ( status === 'loading' && <Loading size="16">{text}</Loading>
<Loading class={bem('loading')} size="16">
{text}
</Loading>
)
]; ];
return ( return (

View File

@ -24,7 +24,7 @@ exports[`change head content when pulling down 3`] = `
<div class="van-pull-refresh"> <div class="van-pull-refresh">
<div class="van-pull-refresh__track" style="transition: 300ms; transform: translate3d(0,50px, 0);"> <div class="van-pull-refresh__track" style="transition: 300ms; transform: translate3d(0,50px, 0);">
<div class="van-pull-refresh__head"> <div class="van-pull-refresh__head">
<div class="van-loading van-loading--circular van-pull-refresh__loading"><span class="van-loading__spinner van-loading__spinner--circular" style="color: rgb(201, 201, 201); width: 16px; height: 16px;"><svg viewBox="25 25 50 50" class="van-loading__circular"><circle cx="50" cy="50" r="20" fill="none"></circle></svg></span><span class="van-loading__text">加载中...</span></div> <div class="van-loading van-loading--circular"><span class="van-loading__spinner van-loading__spinner--circular" style="color: rgb(201, 201, 201); width: 16px; height: 16px;"><svg viewBox="25 25 50 50" class="van-loading__circular"><circle cx="50" cy="50" r="20" fill="none"></circle></svg></span><span class="van-loading__text">加载中...</span></div>
</div> </div>
</div> </div>
</div> </div>
@ -34,7 +34,7 @@ exports[`change head content when pulling down 4`] = `
<div class="van-pull-refresh"> <div class="van-pull-refresh">
<div class="van-pull-refresh__track" style="transition: 300ms; transform: translate3d(0,50px, 0);"> <div class="van-pull-refresh__track" style="transition: 300ms; transform: translate3d(0,50px, 0);">
<div class="van-pull-refresh__head"> <div class="van-pull-refresh__head">
<div class="van-loading van-loading--circular van-pull-refresh__loading"><span class="van-loading__spinner van-loading__spinner--circular" style="color: rgb(201, 201, 201); width: 16px; height: 16px;"><svg viewBox="25 25 50 50" class="van-loading__circular"><circle cx="50" cy="50" r="20" fill="none"></circle></svg></span><span class="van-loading__text">加载中...</span></div> <div class="van-loading van-loading--circular"><span class="van-loading__spinner van-loading__spinner--circular" style="color: rgb(201, 201, 201); width: 16px; height: 16px;"><svg viewBox="25 25 50 50" class="van-loading__circular"><circle cx="50" cy="50" r="20" fill="none"></circle></svg></span><span class="van-loading__text">加载中...</span></div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -67,13 +67,14 @@ export default sfc({
const { type, message } = this; const { type, message } = this;
const style = STYLE.indexOf(type) !== -1 ? 'default' : type; const style = STYLE.indexOf(type) !== -1 ? 'default' : type;
const Content = () => { function Content() {
switch (style) { switch (style) {
case 'text': case 'text':
return <div>{message}</div>; return <div>{message}</div>;
case 'html': case 'html':
return <div domPropsInnerHTML={message} />; return <div domPropsInnerHTML={message} />;
default: }
return [ return [
type === 'loading' ? ( type === 'loading' ? (
<Loading color="white" type={this.loadingType} /> <Loading color="white" type={this.loadingType} />
@ -83,7 +84,6 @@ export default sfc({
isDef(message) && <div class={bem('text')}>{message}</div> isDef(message) && <div class={bem('text')}>{message}</div>
]; ];
} }
};
return ( return (
<transition name="van-fade"> <transition name="van-fade">