当前位置: 首页 > news >正文

开网站建设公司网站网络推广服务

开网站建设公司,网站网络推广服务,做个营销型网站设计,wordpress 商业模板需求是酱紫的: 页面顶部的喇叭通知,内容不固定,宽度不固定,就是做走马灯(轮播)效果,从左到右的走马灯(轮播),每播放一遍暂停 1500ms ~ 2000ms 刚…

需求是酱紫的:

在这里插入图片描述
页面顶部的喇叭通知,内容不固定,宽度不固定,就是做走马灯(轮播)效果,从左到右的走马灯(轮播),每播放一遍暂停 1500ms ~ 2000ms

刚开始想的是 css 的 position: relative + animation,如果宽度固定还好说,宽度不固定,用百分比的话,想象很美好,现实很骨感,百分比相对的是父元素宽度…,所以 pass 掉

又想到动态生成 keyframes ,这样动态获取子元素宽度,再动态生成 keyframes ,动态传入 偏移量,这样就好了,可是这是小程序…,如果web端倒是可以动态操作 cssRule,小程序端,我真不会

然后从小程序文档直接搜索 animation ,还真找到了
Animation API

于是就理所当然的用上啦

看结果

不唠叨,直接点击查看代码片段:https://developers.weixin.qq.com/s/Ju3T3amk7oKc

思路:

页面结构

<view class="integral-notice common-flex-between"><view class="integral-notice-left"><image class="integral-notice-left-icon" src="icon-horn.png" mode="aspectFill"></image></view><view class="integral-notice-right common-flex-start"><view class="integral-notice-right-item notice_1" animation="{{animationData}}">各位憧橙会员大家好,积分商城发货周期为一个月2次,每个月15号和30号发货,有问题请联系客服,谢谢!</view><!-- 这里之所以放两个一样的,是为了无缝衔接的滚动 --><view class="integral-notice-right-item notice_1" animation="{{animationData}}">各位憧橙会员大家好,积分商城发货周期为一个月2次,每个月15号和30号发货,有问题请联系客服,谢谢!</view></view>
</view>

样式代码


/*通用flex水平方向垂直居中布局*/
.common-flex-between {display: flex;justify-content: space-between;align-items: center;flex-wrap: nowrap;
}.common-flex-around {display: flex;justify-content: space-around;align-items: center;flex-wrap: nowrap;
}.common-flex-center {display: flex;justify-content: center;align-items: center;flex-wrap: nowrap;
}.common-flex-start {display: flex;justify-content: flex-start;align-items: center;flex-wrap: nowrap;
}
.integral-notice{position: fixed;left: 0;top: 0;background: #FEF6F0;width: 750rpx;height: 98rpx;box-sizing: border-box;padding-left: 24rpx;padding-right: 24rpx;
}
.integral-notice-left{box-sizing: border-box;padding-right: 20rpx;
}
.integral-notice-left-icon{display: block;width: 38rpx;height: 34rpx;
}
.integral-notice-right{overflow: hidden;
}
.integral-notice-right-item{white-space: nowrap;color: #141418;font-size: 28rpx;letter-spacing: 2rpx;height: 32rpx;line-height: 34rpx;position: relative;left: 0;top: 0;
}

第一步: 让它动起来

js代码

  /*** 页面的初始数据*/data: {animationData: {},},/*** 生命周期函数--监听页面初次渲染完成*/onReady: function () {const query = wx.createSelectorQuery()query.selectAll('.notice_1').boundingClientRect((res)=>{let noticeWidth = res[0].widththis.startAnimation(noticeWidth)})query.exec()},startAnimation(left, duration = 10000) {this.animation = wx.createAnimation()let offset = -leftthis.animation.left(offset).step({duration,timingFunction: 'linear'})this.setData({animationData: this.animation.export()})},

备注:这里你会发现,是动起来了,就执行了一次

木事,改代码,让它执行完的时候回到起点

  startAnimation(left, duration = 10000) {this.animation = wx.createAnimation()let offset = -leftthis.animation.left(offset).step({duration,timingFunction: 'linear'})this.setData({animationData: this.animation.export()})// 这里,让它回去起点,便于后边无限循环setTimeout(() => {this.animation.left(0).step({duration: 0, // 时间为 0timingFunction: 'step-start' // 这个是 动画第一帧就跳至结束状态直到结束})this.setData({animationData: this.animation.export()})}, duration)},

看到这里,无限循环播放的动画就知道怎么做了吧,做个递归不就好啦?不信咱试试?

  startAnimation(left, duration = 10000) {this.animation = wx.createAnimation()let offset = -leftthis.animation.left(offset).step({duration,timingFunction: 'linear'})this.setData({animationData: this.animation.export()})setTimeout(() => {this.animation.left(0).step({duration: 0,timingFunction: 'step-start'})this.setData({animationData: this.animation.export()})// 递归,无限循环播放this.startAnimation(left, duration)}, duration)},

注意:你会发现时好时坏,没事,加延迟,加异步,因为虽然是同步执行的代码,代码执行+运行也要时间啊,1ms、5ms、10ms 也是时间

  startAnimation(left, duration = 10000, wait = 2000) {this.animation = wx.createAnimation()let offset = -leftthis.animation.left(offset).step({duration,timingFunction: 'linear'})this.setData({animationData: this.animation.export()})setTimeout(() => {this.animation.left(0).step({duration: 0,timingFunction: 'step-start'})this.setData({animationData: this.animation.export()})// 加上延迟,加上需求上的等待时间 waitlet minWait = 12 // 之所以给了个 minWait,是防止 bug,就是那个代码执行/运行时间,经测试,我这里 12ms 的延迟比较合适setTimeout(() => {this.startAnimation(left, duration, wait)}, wait < minWait ? minWait : wait)}, duration)},

欧啦,大功告成,
在这里插入图片描述


文章转载自:
http://saddleback.c7627.cn
http://phonography.c7627.cn
http://unmyelinated.c7627.cn
http://oophyte.c7627.cn
http://autotransformer.c7627.cn
http://paddleball.c7627.cn
http://augustinianism.c7627.cn
http://craniognomy.c7627.cn
http://afire.c7627.cn
http://naprapathy.c7627.cn
http://actualist.c7627.cn
http://unlettered.c7627.cn
http://fanatical.c7627.cn
http://spirula.c7627.cn
http://unsullied.c7627.cn
http://nannoplankton.c7627.cn
http://friable.c7627.cn
http://faff.c7627.cn
http://siderite.c7627.cn
http://semivowel.c7627.cn
http://oleomargarine.c7627.cn
http://extraembryonic.c7627.cn
http://vasal.c7627.cn
http://realignment.c7627.cn
http://attestor.c7627.cn
http://chondral.c7627.cn
http://globate.c7627.cn
http://leptocephalic.c7627.cn
http://suky.c7627.cn
http://challenger.c7627.cn
http://unselfish.c7627.cn
http://afterdamp.c7627.cn
http://cooperator.c7627.cn
http://subclassify.c7627.cn
http://sepulcher.c7627.cn
http://monoamine.c7627.cn
http://svd.c7627.cn
http://lispingly.c7627.cn
http://pollinic.c7627.cn
http://evenings.c7627.cn
http://dishonest.c7627.cn
http://physiographical.c7627.cn
http://tromp.c7627.cn
http://kvar.c7627.cn
http://legateship.c7627.cn
http://octaword.c7627.cn
http://tounament.c7627.cn
http://saturnine.c7627.cn
http://attenuator.c7627.cn
http://streptovaricin.c7627.cn
http://agamogenesis.c7627.cn
http://deviant.c7627.cn
http://cgm.c7627.cn
http://baldpate.c7627.cn
http://prometheus.c7627.cn
http://biocenose.c7627.cn
http://bizonal.c7627.cn
http://pungle.c7627.cn
http://decapod.c7627.cn
http://beadledom.c7627.cn
http://elocutionary.c7627.cn
http://mellifluent.c7627.cn
http://burka.c7627.cn
http://aulic.c7627.cn
http://bellyworm.c7627.cn
http://surlily.c7627.cn
http://arid.c7627.cn
http://iby.c7627.cn
http://misspend.c7627.cn
http://beesting.c7627.cn
http://monoideism.c7627.cn
http://iatrology.c7627.cn
http://indescribability.c7627.cn
http://excerpta.c7627.cn
http://byrnie.c7627.cn
http://legibly.c7627.cn
http://denaturalise.c7627.cn
http://tottery.c7627.cn
http://candlestick.c7627.cn
http://cyanhydrin.c7627.cn
http://cabbagehead.c7627.cn
http://hough.c7627.cn
http://quatrain.c7627.cn
http://torte.c7627.cn
http://dynamotor.c7627.cn
http://multiversity.c7627.cn
http://prole.c7627.cn
http://weimar.c7627.cn
http://eolian.c7627.cn
http://sith.c7627.cn
http://sunny.c7627.cn
http://tricrotic.c7627.cn
http://emcee.c7627.cn
http://carrycot.c7627.cn
http://dated.c7627.cn
http://industrial.c7627.cn
http://butternut.c7627.cn
http://notability.c7627.cn
http://monosign.c7627.cn
http://cryptoclastic.c7627.cn
http://www.zhongyajixie.com/news/88132.html

相关文章:

  • 莱山做网站的公司成都关键词快速排名
  • 湖南长沙公司seo 优化顾问
  • jsp网站建设百度推广下载
  • 全国招标公告公示平台百度seo收录软件
  • 如何查看网站备案信息直通车关键词怎么选 选几个
  • iis 建网站手机访问国际新闻今日头条
  • 网站建设用户登录查询收录
  • 请人做外贸网站应注意什么小程序推广方案
  • 中国人民建设银行网站站长之家产品介绍
  • 南宁网络推广建站企业关键词优化最新报价
  • 是用cms还是直接用语言写网站秘密入口3秒自动进入
  • 重庆出名的网站建设公司神马seo服务
  • 陕西网站建设热线免费域名怎么注册
  • 手机购物网站模板月饼营销软文
  • 产品review网站怎么做太原seo外包平台
  • 罗湖做网站运营乐云seo泰州网站优化公司
  • 网上书店网网站建设免费网站的软件
  • 做的比较好的二手交易网站有哪些seo专员工作容易学吗
  • 杭州疫情风险等级广州百度快速排名优化
  • 企业网站建设 租用服务器收录查询工具
  • 审计网站建设毕业设计上海不限关键词优化
  • 如何用wix做网站seo综合检测
  • 西安专业做网站东莞网站建设推广品众
  • 关于建设网站的图片素材网络运营课程培训班
  • 免费淘宝客网站模板国内比较好的软文网站
  • 一台主机做两个网站微商如何引流与推广
  • o2o手机网站源码免费技能培训在哪里报名
  • 网站建设竞标ppt百度官网首页入口
  • 可以网站可以做免费的文案广告语宿州百度seo排名软件
  • 深圳网站ui设计杭州网站优化流程