Last active
May 5, 2017 04:59
-
-
Save rikumi/34866cb777f591e91d51c857ccb0d795 to your computer and use it in GitHub Desktop.
微信小程序缩放式轮播图实现
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Page({ | |
data:{ | |
curIndex: 1 // 此处可指定初始状态显示第几个页面 | |
}, | |
onSwiperChange: function(event) { | |
this.setData({ curIndex: event.detail.current }) | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 此处duration时间应当与下面的-webkit-transition一致 --> | |
<swiper duration="300" bindchange="onSwiperChange" current="{{ curIndex }}"> | |
<swiper-item wx:for="[0, 1, 2]" style="overflow: visible;"> | |
<view style="width: 100%; height: 100%; background: #2bbfff; -webkit-transform: scale({{ curIndex == index ? 0.78 : 0.7 }}) translate({{ (curIndex == index - 1 || curIndex == index + 1) ? (curIndex - index) * 30 : 0 }}%, 0); -webkit-transition: .3s; position: relative;"> | |
</view> | |
</swiper-item> | |
</swiper> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment