const VALID_MODE = ['closeable', 'link'];
const FONT_COLOR = '#f60';
const BG_COLOR = '#fff7cc';
Component({
options: {
addGlobalClass: true
},
externalClasses: ['custom-class'],
properties: {
text: {
type: String,
value: '',
observer() {
this.setData({}, this._init);
}
},
mode: {
type: String,
value: ''
},
url: {
type: String,
value: ''
},
openType: {
type: String,
value: 'navigate'
},
delay: {
type: Number,
value: 0
},
speed: {
type: Number,
value: 50
},
scrollable: {
type: Boolean,
value: true
},
leftIcon: {
type: String,
value: ''
},
color: {
type: String,
value: FONT_COLOR
},
backgroundColor: {
type: String,
value: BG_COLOR
}
},
data: {
show: true,
hasRightIcon: false,
width: undefined,
wrapWidth: undefined,
elapse: undefined,
animation: null,
resetAnimation: null,
timer: null
},
attached() {
const { mode } = this.data;
if (mode && this._checkMode(mode)) {
this.setData({
hasRightIcon: true
});
}
},
detached() {
const { timer } = this.data;
timer && clearTimeout(timer);
},
methods: {
_checkMode(val) {
const isValidMode = ~VALID_MODE.indexOf(val);
if (!isValidMode) {
console.warn(`mode only accept value of ${VALID_MODE}, now get ${val}.`);
}
return isValidMode;
},
_init() {
wx.createSelectorQuery()
.in(this)
.select('.van-notice-bar__content')
.boundingClientRect((rect) => {
if (!rect || !rect.width) {
return;
}
this.setData({
width: rect.width
});
wx.createSelectorQuery()
.in(this)
.select('.van-notice-bar__content-wrap')
.boundingClientRect((rect) => {
if (!rect || !rect.width) {
return;
}
const wrapWidth = rect.width;
const {
width, speed, scrollable, delay
} = this.data;
if (scrollable && wrapWidth < width) {
const elapse = width / speed * 1000;
const animation = wx.createAnimation({
duration: elapse,
timeingFunction: 'linear',
delay
});
const resetAnimation = wx.createAnimation({
duration: 0,
timeingFunction: 'linear'
});
this.setData({
elapse,
wrapWidth,
animation,
resetAnimation
}, () => {
this._scroll();
});
}
})
.exec();
})
.exec();
},
_scroll() {
const {
animation, resetAnimation, wrapWidth, elapse, speed
} = this.data;
resetAnimation.translateX(wrapWidth).step();
const animationData = animation.translateX(-(elapse * speed) / 1000).step();
this.setData({
animationData: resetAnimation.export()
});
setTimeout(() => {
this.setData({
animationData: animationData.export()
});
}, 100);
const timer = setTimeout(() => {
this._scroll();
}, elapse);
this.setData({
timer
});
},
_handleButtonClick() {
const { timer } = this.data;
timer && clearTimeout(timer);
this.setData({
show: false,
timer: null
});
},
onClick(event) {
this.triggerEvent('click', event);
}
}
});
没有合适的资源?快使用搜索试试~ 我知道了~
小程序云开发项目实战 +私房书柜项目源码,项目经过测试,可完美运行!
共157个文件
js:43个
wxss:41个
json:37个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 73 浏览量
2023-06-19
21:05:27
上传
评论
收藏 87KB ZIP 举报
温馨提示
小程序云开发项目实战 +私房书柜项目源码,项目经过测试,可完美运行! 小程序云开发项目实战 +私房书柜项目源码,项目经过测试,可完美运行! 小程序云开发项目实战 +私房书柜项目源码,项目经过测试,可完美运行! 小程序云开发项目实战 +私房书柜项目源码,项目经过测试,可完美运行! 小程序云开发项目实战 +私房书柜项目源码,项目经过测试,可完美运行! 小程序云开发项目实战 +私房书柜项目源码,项目经过测试,可完美运行! 小程序云开发项目实战 +私房书柜项目源码,项目经过测试,可完美运行! 小程序云开发项目实战 +私房书柜项目源码,项目经过测试,可完美运行! 小程序云开发项目实战 +私房书柜项目源码,项目经过测试,可完美运行! 小程序云开发项目实战 +私房书柜项目源码,项目经过测试,可完美运行! 小程序云开发项目实战 +私房书柜项目源码,项目经过测试,可完美运行! 小程序云开发项目实战 +私房书柜项目源码,项目经过测试,可完美运行! 小程序云开发项目实战 +私房书柜项目源码,项目经过测试,可完美运行! 小程序云开发项目实战 +私房书柜项目源码,项目经过测试,可完美运
资源推荐
资源详情
资源评论
收起资源包目录
小程序云开发项目实战 +私房书柜项目源码,项目经过测试,可完美运行! (157个子文件)
.gitignore 2KB
.gitignore 2KB
.gitignore 2KB
index.js 4KB
index.js 2KB
index.js 2KB
index.js 2KB
index.js 2KB
scanCode.js 2KB
bookDetail.js 2KB
index.js 1KB
index.js 1KB
toast.js 1KB
button.js 1KB
behaviors.js 1KB
index.js 1KB
index.js 1KB
index.js 1KB
index.js 1017B
index.js 892B
index.js 811B
index.js 755B
index.js 709B
index.js 699B
classnames.js 679B
touch.js 662B
index.js 570B
index.js 568B
notify.js 522B
index.js 509B
index.js 507B
index.js 501B
index.js 496B
index.js 486B
index.js 468B
index.js 420B
index.js 377B
index.js 341B
index.js 302B
index.js 280B
index.js 273B
app.js 252B
index.js 236B
index.js 229B
index.js 177B
index.js 174B
package-lock.json 14KB
project.config.json 898B
app.json 521B
package.json 317B
package.json 260B
index.json 207B
index.json 158B
index.json 154B
scanCode.json 152B
index.json 121B
index.json 119B
index.json 116B
index.json 96B
index.json 96B
index.json 90B
index.json 89B
index.json 84B
index.json 84B
index.json 84B
index.json 84B
index.json 84B
index.json 83B
index.json 83B
bookDetail.json 74B
index.json 24B
index.json 24B
index.json 24B
index.json 24B
index.json 24B
index.json 24B
index.json 24B
index.json 24B
index.json 23B
index.json 23B
index.json 23B
index.json 23B
index.json 23B
yarn.lock 11KB
index.wxml 2KB
index.wxml 1KB
index.wxml 1KB
index.wxml 944B
index.wxml 939B
index.wxml 914B
index.wxml 887B
index.wxml 887B
index.wxml 873B
index.wxml 852B
index.wxml 761B
index.wxml 650B
index.wxml 572B
index.wxml 537B
index.wxml 507B
index.wxml 369B
共 157 条
- 1
- 2
资源评论
白话机器学习
- 粉丝: 8254
- 资源: 7687
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功