查看: 22565|回复: 11
打印 上一主题 下一主题

swiper-container搞定自适应

[复制链接]
  • TA的每日心情
    慵懒
    2019-8-26 15:39
  • 签到天数: 1 天

    [LV.1]初来乍到

    0

    主题

    12

    帖子

    96

    积分

    注册会员

    Rank: 2

    积分
    96
    楼主
    发表于 2015-9-19 15:46:36 | 显示全部楼层
    onSlideChangeEnd  不能触发....  怎么没人回答呢?帮帮我们这些菜鸟啊
    回复

    使用道具 举报

  • TA的每日心情
    慵懒
    2019-8-26 15:39
  • 签到天数: 1 天

    [LV.1]初来乍到

    0

    主题

    12

    帖子

    96

    积分

    注册会员

    Rank: 2

    积分
    96
    沙发
    发表于 2015-9-19 17:03:19 | 显示全部楼层
    疯子蚁 发表于 2015-9-19 15:46
    onSlideChangeEnd  不能触发....  怎么没人回答呢?帮帮我们这些菜鸟啊

    http://www.swiper.com.cn/api/touch/2015/0308/205.html  看我直播  现在算出的高度竟然一样的 继续
    回复

    使用道具 举报

  • TA的每日心情
    慵懒
    2019-8-26 15:39
  • 签到天数: 1 天

    [LV.1]初来乍到

    0

    主题

    12

    帖子

    96

    积分

    注册会员

    Rank: 2

    积分
    96
    板凳
    发表于 2015-9-21 10:39:45 | 显示全部楼层
    本帖最后由 疯子蚁 于 2015-9-21 10:42 编辑
    1. var eHeight0,eHeight1,eHeight2;
    2.                         var mySwiper = new Swiper('.swiper-container', {
    3.                                 resistanceRatio : 1,
    4.                                 onInit: function(swiper){
    5.                                         eHeight0 = swiper.slides[0].offsetHeight+'px';
    6.                                         eHeight1 = swiper.slides[1].offsetHeight+'px';
    7.                                         eHeight2 = swiper.slides[2].offsetHeight+'px';
    8.                                         alert(eHeight2)
    9.                                         switch(swiper.activeIndex)
    10.                                         {
    11.                                                 case 0:
    12.                                                 swiper.container[0].style.height=eHeight0;
    13.                                                 break;
    14.                                                 case 1:
    15.                                                 swiper.container[0].style.height=eHeight1;
    16.                                                 break;
    17.                                                 case 2:
    18.                                                 swiper.container[0].style.height=eHeight2;
    19.                                                 break;
    20.                                         }
    21. //                swiper.container[0].style.height=swiper.slides[swiper.activeIndex].offsetHeight+'px';
    22.             },onSlideChangeStart: function(swiper){
    23.                             //var eHeight0 = swiper.slides[0].offsetHeight+'px';
    24.                                         //var eHeight1 = swiper.slides[1].offsetHeight+'px';
    25.                                         //var eHeight2 = swiper.slides[2].offsetHeight+'px';
    26.                                         switch(swiper.activeIndex)
    27.                                         {
    28.                                                 case 0:
    29.                                                 swiper.container[0].style.height=eHeight0;
    30.                                                 alert('0');
    31.                                                 break;
    32.                                                 case 1:
    33.                                                 swiper.container[0].style.height=eHeight1;
    34.                                                 alert('1')
    35.                                                 break;
    36.                                                 case 2:
    37.                                                 swiper.container[0].style.height=eHeight2;
    38.                                                 alert('2')
    39.                                                 break;
    40.                                         }
    41. //                swiper.container[0].style.height=swiper.slides[swiper.activeIndex].offsetHeight+'px';
    42. //                alert(swiper.activeIndex);
    43. //              alert(swiper.slides[swiper.activeIndex].offsetHeight+'px');
    44.                 //alert(swiper.slides[swiper.activeIndex].offsetHeight+'px');
    45.             },
    46.                                 direction: 'horizontal',
    47.                                 loop: false,
    48.                                 calculateHeight: true,
    49.                                 effect: 'coverflow',
    50.                                 useCSS3Transforms:'false',
    51.                                 // 如果需要分页器
    52.                                 pagination: '.swiper-pagination',
    53.                                 // 如果需要前进后退按钮
    54.                                 // nextButton: '.swiper-button-next',
    55.                                 // prevButton: '.swiper-button-prev',
    56.                                 // 如果需要滚动条
    57.                                 //                                 scrollbar: '.swiper-scrollbar',
    58.                         })
    复制代码
    先将就吧  等大神来
    回复

    使用道具 举报

  • TA的每日心情
    慵懒
    2019-8-26 15:39
  • 签到天数: 1 天

    [LV.1]初来乍到

    0

    主题

    12

    帖子

    96

    积分

    注册会员

    Rank: 2

    积分
    96
    地板
    发表于 2015-9-24 10:35:34 | 显示全部楼层
    疯子蚁 发表于 2015-9-21 10:39
    先将就吧  等大神来

    我又来了   这么写火狐都不认识.
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    Archiver|手机版|小黑屋|Swiper中文网 ( 粤ICP备15001020号

    GMT+8, 2024-5-18 10:37 , Processed in 0.064844 second(s), 25 queries .

    Powered by Discuz! X3.2

    © 2001-2013 Comsenz Inc.

    快速回复 返回顶部 返回列表