jeasonstudio / blog

Blog of Jeason
https://jeasonstudio.github.io/blog/
MIT License
3 stars 1 forks source link

Ripples.wxss——微信小程序css库 #11

Open jeasonstudio opened 6 years ago

jeasonstudio commented 6 years ago

Ripples.wxss——微信小程序css库

写在前面

先给大家拜个年,祝大家鸡年大吉大利,工作顺顺利利,家庭和和睦睦,新年无 BUG!!

1月9日,微信正式发布微信小程序,作为开发人员,除了关注技术方面的一些创新与壁垒,也要多用多看,分析这些小程序的优点与不足,有时候作为一个 web 前端,也十分需要 UI/UX 方面敏锐的嗅觉。

今天我们来说说小程序的 UX (或者说:微交互)。团队的技术水平决定产品的下限,对微交互的极致追求决定了产品的上限。

举个简单的例子:我们在使用 wx,showModal(obj) 、并且交互层级分明的情况下,可以给底层加一个 「高斯模糊」,例如:

<view class="page {{isBlur ? 'blur':''}}">
.blur {filter: blur(6rpx);}

有时候几行简单的代码就能给一款产品带来高一个层次的体验。

下面说我们今天的重头戏,为微信小程序定制的 css3 动效库 Ripples.wxss**

GitHub 地址:jeasonstudio/Ripples.wxss**

希望大家不要吝惜自己的 star~ 。

声明:其中大部分动效来自 Animate.css**

安装

npm install ripples.wxss --save

使用

<view class="ripple infinite bounce">element</view>

使用实例

image

//imdex.js
Page({
  data: {
      bounceShow: false
  },
  showBounce: function () {
      let that = this
      that.setData({
          bounceShow: true
      })
      setTimeout(function() {
          that.setData({
              bounceShow: false
          }, 2000)
      })
}}
/* imdex.wxss */
@import "ripples.wxss";
<!--index.wxml-->
<view class="ripple {{bounceShow ? bounce:''}}">bounce</view>

个性化引入

Ripple.wxss 使用 gulp** 进行 wxss 的格式化和压缩,所以你也可以用它来个性化生成 「Ripples.min.wxss」 后引入,以避免代码冗余。

如下:

"bouncing_entrances": [
    "bounceIn",
    "bounceInDown",
    "bounceInLeft",
    "bounceInRight",
    "bounceInUp"
  ]

最后

文章如有不当,请各位批评指正。

欢迎大家关注我的专栏:知乎专栏-代码小白的日常

照旧放上 GIthub 地址:jeasonstudio/Ripples.wxss**