帖子
帖子
用户
博客
课程
显示全部楼层
14
帖子
0
勋章
167
Y币

avm 滚动字体效果

[复制链接]
发表于 2021-1-15 10:16:46
本帖最后由 galen-bin 于 2021-1-15 10:49 编辑

template:
        <view class="content-wrap">
                    <view class="msg_tz">
                        <image class="notetz" src="../../image/icon/notetz.png"/>                                      
                        <text class="notetz_msg" style={{'left:'+note_left}}>
                            {{note_msg}}
                        </text>         
                    </view>

                </view>
css:

.content-wrap {
    padding: 8px 0;
    border-bottom:  0.8px solid #f1f1f1;
}
.msg_tz
{
    display: flex;
    flex-direction: row;
    padding-left: 10px;

}
.notetz
{
    width: 20px;
    height: 20px;
    position: absolute;
    z-index: 1000;
    left:8;
    background-color: #fff;
}
.notetz_msg
{
    font-size: 12px;
    height: 20px;
    line-height: 20px;
    position: relative;   
    width: 100%;
    padding-top: 2px;
}




js:
apiready() {

        this.note_left=this.winWidth-40;

    }

,onshow() {

        this.setint=setInterval(() => {
            this.note_left-=1;      
            if(this.note_left<=-(this.winWidth-40))
            {
                console.log(this.note_left);
                this.note_left=this.winWidth-40;            
            }
        },30);

    },
    onHide(){
        clearInterval(this.setint);
    }


本帖子中包含更多资源,您需要 登录 才可以下载或查看,没有帐号?立即注册

X
380
帖子
4
勋章
6
Y币
你的代码没发完整
283
帖子
4
勋章
4927
Y币
贡献一下AVM代码,感谢楼主提供思路

  1. <template>
  2.         <view class="page">
  3.             <view class="walking_lantern_one">
  4.                <text class="walking_lantern_one_notetz_msg" style={{'left:'+note_left}}>
  5.                  {{note_msg}}
  6.                </text>
  7.             </view>
  8.         </view>
  9. </template>
  10. <style>
  11.     .page{
  12.         background: #000;
  13.         width: 100%;
  14.         height: 100%;
  15.         padding-top: 100px;
  16.     }
  17.     .walking_lantern_one{
  18.         background: #fff;
  19.         flex-direction: row;
  20.     }
  21.     .walking_lantern_one_notetz_msg{
  22.         font-size: 13px;
  23.         height: 20px;
  24.         line-height: 20px;
  25.         color: #444;
  26.         width: 100%;
  27.     }
  28. </style>
  29. <script>
  30. export default {
  31.     name: "walking_lantern_one",
  32.     data() {
  33.         return {
  34.             note_left:0,
  35.             winWidth:0,
  36.             note_msg:"圣诞节快圣诞节快上班都没上班的吗你水果的话术时代就开始哭的好时机肯定会接受,不得你搜不到吗你说过话就是打开"
  37.         }
  38.     },
  39.     apiready() {
  40.         this.data.winWidth = api.winWidth;
  41.         var setint = setInterval(() => {
  42.             this.data.note_left-=1;
  43.             if( this.data.note_left <= -(this.data.winWidth) ){
  44.                 this.data.note_left=this.data.winWidth;            
  45.             }
  46.         },30);
  47.     },
  48. };
  49. </script>
复制代码

移除定时器啥的都没写 自己鼓捣吧

14
帖子
0
勋章
167
Y币
imo. 发表于 2021-2-4 11:50
贡献一下AVM代码,感谢楼主提供思路

onHide(){
        clearInterval(this.setint);
    }
14
帖子
0
勋章
167
Y币

核心代码就这些
您需要登录后才可以回帖 登录

本版积分规则