normal video.mp4 (2.74MB)

解析

思路
1.由于要兼容H5使用c3动画去实现
2.计算自动滚动高度

动画
所使用的动画效果是是一个向上弹跳进入动画,根据实际情况去调整所需要的值

  1. //animation
  2. 动画name,动画时长,延迟执行时间,运动效果,规定动画在播放之前或之后其动画效果是否可见
  3. #animation{
  4. -webkit-animation:bounceInUp 1s .2s ease both;
  5. -moz-animation:bounceInUp 1s .2s ease both;
  6. }
  7. @-webkit-keyframes bounceInUp{
  8. 0%{
  9. opacity:0;
  10. -webkit-transform:translateY(2000px)
  11. }
  12. 60%{
  13. opacity:1;
  14. -webkit-transform:translateY(-30px)
  15. }
  16. 80%{
  17. -webkit-transform:translateY(10px)
  18. }
  19. 100%{
  20. -webkit-transform:translateY(0)}
  21. }
  22. @-moz-keyframes bounceInUp{
  23. 0%{
  24. opacity:0;
  25. -moz-transform:translateY(2000px)
  26. }
  27. 60%{
  28. opacity:1;-moz-transform:translateY(-30px)
  29. }
  30. 80%{
  31. -moz-transform:translateY(10px)
  32. }
  33. 100%{
  34. -moz-transform:translateY(0)}
  35. }

计算高度

  1. 注:由于导航栏为自定义需要计算statusBarHeightheaderHeight的高度。
  2. <scroll-view
  3. scroll-y="true"
  4. :show-scrollbar="false"
  5. :scroll-top="top"
  6. :scroll-with-animation="true"
  7. class="container-scroll"
  8. >
  9. <view class="container-wrap">
  10. //...
  11. </view>
  12. </scroll-view>
  13. this.$nextTick(()=>{
  14. let view = uni.createSelectorQuery().in(this).select(".container-wrap");
  15. view.boundingClientRect(data => {
  16. this.top = data.height + this.statusBarHeight + this.headerHeight - this.windowHeight - 20;
  17. }).exec();
  18. })