• 微信小程序动画实现(API,css)


    微信小程序动画API实现

    index.js

    clicktap:function(){
        var Animation=wx.createAnimation({
            duration: 2000,
        })
        Animation.rotateZ(-45).step()
        this.setData({
        animation:Animation.export()
        })
    }
    

    index.wxml

    <view>
      <view class="box" animation="{{animation}}"></view>
      <view class="click" bindtap="clicktap">点击</view>
    </view>
    

    index.wxss

    .box{
      background-color: blanchedalmond;
       100rpx;
      height: 100rpx;
      margin: auto;
      margin-top: 50rpx;
    }
    .click{
      margin: auto;
      background-color: #fcc;
       150rpx;
      text-align: center;
      color: #FFf;
      margin-top: 50rpx;
      padding: 10rpx;
      border-radius: 10rpx;
    }
    

    效果:

    微信小程序动画css实现

    .box {
      background-color: blanchedalmond;
       100rpx;
      height: 100rpx;
      margin: auto;
      margin-top: 50rpx;
      animation: animation 6s linear infinite;
      animation-delay: 1s
    }
    @keyframes animation {
      0% {
        transform: rotateZ(0deg);
      }
      50% {
        transform: rotateZ(-45deg);
        background-color: cadetblue;
      }
      100% {
        transform: rotateZ(0deg);
        background-color: burlywood;
      }
    }
    

    效果:

    给.box的父元素加个背景,.box去掉背景色,view标签换成<image></image>,可以做出如下效果:

  • 相关阅读:
    vi和vim区别
    基本命令
    Ubentu搭建nfs服务器
    Ubuntu + CentOS7 搭建tftp Server
    基于UP-CUP6410点灯实验完成
    搭建服务器(3)
    搭建服务器(2)
    CentOS7.1搭建服务器篇(1)
    关于科台斯k97gprs调试记录(1)
    Arm环境搭建-基于博创科技(CentOS7.0系统安装篇1)
  • 原文地址:https://www.cnblogs.com/kerin/p/14216337.html
Copyright © 2020-2023  润新知