Browse Source

跑马灯修改

9-plugin-notice
aBin 4 years ago
parent
commit
6d0d7ca6d0
  1. 32
      index.html

32
index.html

@ -25,9 +25,11 @@
<view data-pid="1420652719055839232" data-uid="1298194698783170560" data-rid="xxx" data-tid="xxx" data-did="xxx"> <view data-pid="1420652719055839232" data-uid="1298194698783170560" data-rid="xxx" data-tid="xxx" data-did="xxx">
<!--绿道一键通知--> <!--绿道一键通知-->
<div data-root="p1419895620596146176"> <div data-root="p1419895620596146176">
<div style="position: relative;" class="h-7 overflow-hidden"> <div style="position: relative;" class="h-7 overflow-hidden box">
<div class="txt text-xl"> <!-- overflow-hidden -->
<!-- 请<span style="color: #f00">XXX</span>到<span style="color: #f00">XX号窗口</span>交费 --> <div class="txt text-xl" style="white-space:nowrap;word-wrap: break-all;">
<!-- 请<span style="color: #f00">XXX</span>到<span style="color: #f00">XX号窗口</span>交费&nbsp;&nbsp;&nbsp;&nbsp;
<span style="color: #f00">XXX</span><span style="color: #f00">XX号窗口</span>交费 -->
</div> </div>
</div> </div>
</div> </div>
@ -101,7 +103,7 @@
}).then(function(res){ }).then(function(res){
const { success, code, data, msg } = res; const { success, code, data, msg } = res;
if (success && code === 200) { if (success && code === 200) {
if(data.content !== this.content){ if(data.content !== that.content){
that.setDate(data.content) that.setDate(data.content)
} }
} else { } else {
@ -112,28 +114,36 @@
// 界面渲染 // 界面渲染
setDate(res) { setDate(res) {
if(res !== this.content){ var box = this.dom.querySelector('.box'); //获取标签
this.content = res var oTxt = this.dom.querySelector('.txt'); //获取标签
this.content = res
oTxt.innerHTML = this.content
// 设置宽度
if(res.length < 88){
oTxt.style.width = "70%"
}else{
oTxt.style.width = "140%"
} }
var textLeft = 0 var textLeft = 0
var oTxt = this.dom.querySelector('.txt'); //获取标签
if(this.divWidth === 0) { if(this.divWidth === 0) {
this.divWidth = oTxt.offsetWidth this.divWidth = oTxt.offsetWidth
textLeft = box.offsetWidth - 1
} }
oTxt.innerHTML = res
var that = this var that = this
clearInterval(this.timeId); clearInterval(this.timeId);
this.timeId = null this.timeId = null
if(!this.timeId) { if(!this.timeId) {
this.timeId = setInterval(function (){ this.timeId = setInterval(function (){
//通过定时器重复动作 //通过定时器重复动作
oTxt.style.position = 'absolute'; // oTxt.style.position = 'absolute';
if(-textLeft < that.divWidth + 30){ if(textLeft > -oTxt.offsetWidth && textLeft < box.offsetWidth){
textLeft--; textLeft--;
var leftPX = textLeft + 'px'; var leftPX = textLeft + 'px';
oTxt.style.transform = `translate3d(${leftPX},0,0)` oTxt.style.transform = `translate3d(${leftPX},0,0)`
} else { } else {
clearInterval(this.timeId); textLeft = box.offsetWidth - 1
// clearInterval(this.timeId);
} }
},20) },20)
} }

Loading…
Cancel
Save