Vue # 进度条_this

type: String,
default: ‘default’,
validator (value) {
return [‘default’, ‘small’].includes(value)
}
},
waiting: {
type: Boolean,
default: false
}
},
destroy () {
window.removeEventListener(‘resize’, debounce(this.handleResize, 50))
},
mounted () {
this.changeProgressbarWidth(this.percent)
let _this = this
window.addEventListener(‘resize’, debounce(this.handleResize, 50))
const virtualBar = this.KaTeX parse error: Expected '}', got 'EOF' at end of input: …ssBar = \_this.refs.progressBar
let pageX = e.pageX
let diff = pageX - progressBar.getBoundingClientRect().left
let percent = (diff / progressBar.clientWidth).toFixed(2)
_this.KaTeX parse error: Expected 'EOF', got '}' at position 45: …X, percent }) }̲, 200)) virtua…emit(‘virtualBarLeave’)
}, 200))
},
computed: {
handleCls () {
return this.size === ‘small’
? ‘handle small’
: ‘handle’
}
},
watch: {
percent (newPercent) {
if (newPercent >= 0 && !this.mouse.isDown) {
this.changeProgressbarWidth(newPercent)
}
},
bufferedPercent (newPercent) {
this.changeBufferedWidth(newPercent)
}
},
methods: {
handleResize () {
this.changeBufferedWidth(this.bufferedPercent)
this.changeProgressbarWidth(this.percent)
},
onMouseDown (e) {
e.preventDefault()
this.mouse.startX = e.pageX
this.mouse.isDown = true
this.mouse.left = this.KaTeX parse error: Expected '}', got 'EOF' at end of input: …ressBar = this.refs.progressBar
const progress = this.refs.progressconstprogressBarWidth=progressBar.getBoundingClientRect().widththis.mouse.moveX=e.pageXletdiffX=this.mouse.moveX−this.mouse.startX+this.mouse.leftif(diffX<0)diffX=0if(diffX>progressBarWidth)diffX=progressBarWidththis.progressOffsetWidth=diffXthis.progressbarTranslateX=diffXthis.refs.progress const progressBarWidth = progressBar.getBoundingClientRect().width this.mouse.moveX = e.pageX let diffX = this.mouse.moveX - this.mouse.startX + this.mouse.left if (diffX < 0) { diffX = 0 } if (diffX > progressBarWidth) { diffX = progressBarWidth } this.progressOffsetWidth = diffX this.progressbarTranslateX = diffX this.refs.progressconstprogressBarWidth=progressBar.getBoundingClientRect().widththis.mouse.moveX=e.pageXletdiffX=this.mouse.moveXthis.mouse.startX+this.mouse.leftif(diffX<0)diffX=0if(diffX>progressBarWidth)diffX=progressBarWidththis.progressOffsetWidth=diffXthis.progressbarTranslateX=diffXthis.emit(‘percentChanging’, this.calcPercent())
}
document.onmouseup = e => {
if (!this.mouse.isDown) return
this.mouse.isDown = false
document.onmousemove = null
this.KaTeX parse error: Expected 'EOF', got '}' at position 45: …alcPercent()) }̲ }, progressC…refs.progressBar.getBoundingClientRect()
const offsetWidth = e.pageX - rect.left
this.progressOffsetWidth = offsetWidth
this.progressbarTranslateX = offsetWidth
this.KaTeX parse error: Expected 'EOF', got '}' at position 45: …alcPercent()) }̲, calcPercent …refs.progressBar.clientWidth).toFixed(2)
},
changeProgressbarWidth (percent) {
const barWidth = this.KaTeX parse error: Undefined control sequence: \* at position 77: …idth = percent \̲*̲ barWidth this…refs.progressBar.getBoundingClientRect().width
const offsetWidth = percent * barWidth
this.bufferedOffsetWidth = offsetWidth
}
}
}

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值