手机端--swiper一屏展示下个轮播的一半的效果

摘要:
手机屏展示这样的效果,用swiper去实现,˂viewclass="mas-promo-swiper-scroll-wrapper":style="{transform:'translateX'}"//最主要的就是设置previous-marginnext-margin的值!并且设置父元素的平移距离,,并且在滑动到第一个或者最后一个时更改相对应的值!这样在改变父元素的平移距离的时候就不会有跳动感觉了}.swiper-wrapper{overflow:visible;}.swiper-item{display:flex;justify-content:center;align-items:center;}.mas-promo-swiper-item-image-wrapperimage{display:block;620rpx;height:164rpx;border-radius:16rpx;}

手机端--swiper一屏展示下个轮播的一半的效果第1张

手机屏展示这样的效果,用swiper去实现,

<template>
  <view class="container">
    <view
      class="mas-promo-swiper-scroll-wrapper"
      :style="{ transform:'translateX(' +swiperMarginLeft+'rpx)'}"   //最主要的就是设置 previous-margin next-margin的值!并且设置父元素的平移距离,,并且在滑动到第一个或者最后一个时更改相对应的值!
    >
      <swiper
        class="swiper-wrapper"previousMargin="30rpx"nextMargin="30rpx"@change="changeSwiperItem"
      >
        <swiper-item
          v-for="(item, index) in list":key="index"class="swiper-item"
        >
          <view class="mas-promo-swiper-item-image-wrapper">
            <image :src="http://t.zoukankan.com/item.elememtIcon" />
          </view>
        </swiper-item>
      </swiper>
    </view>
  </view>
</template>

<script lang="ts">import { Vue, Component, Prop } from 'vue-property-decorator';
import * as util from '@/util/util.ts';

@Component
export defaultclass mySwiper extends Vue {
  private swiperMarginLeft: Number = -48;

  private interval: any = 5000;

  private allowClick: any = true;

  private currentIndex: Number = 0;
  private list: any =[];
changeSwiperItem(e) {
    // TODO 滑动的同时动态修改margin-left会有抖动
    var itemId = e.detail.current;
    var bannerList = this.list;
    this.currentIndex = itemId;

    if (itemId === 0) {
      this.swiperMarginLeft = -48;
    } else if (itemId === bannerList.length - 1) {
      this.swiperMarginLeft = 48;
    } else {
      this.swiperMarginLeft = 0;
    }
  }
}
</script>

<style lang="less" scoped>.container {
  overflow: hidden;
}

.mas-promo-swiper-scroll-wrapper {
transition: all 0.3s ease-out;//记得为父元素加个动画!这样在改变父元素的平移距离的时候就不会有跳动感觉了
}
.swiper-wrapper {
  overflow: visible;
}
.swiper-item {
  display: flex;
  justify-content: center;
  align-items: center;
}

.mas-promo-swiper-item-image-wrapper image {
  display: block;
   620rpx;
  height: 164rpx;
  border-radius: 16rpx;
}
</style>

免责声明:文章转载自《手机端--swiper一屏展示下个轮播的一半的效果》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇让你发布的nuget包支持源代码调试HTTP RFC(自学心得)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

vue 好用的轮播插件之一 vue-seamless-scroll

1.安装 cnpm i vue-seamless-scroll -S 2.组件调用importvueSeamlessfrom"vue-seamless-scroll"; (或者全局注册) 3.https://www.npmjs.com/package/vue-seamless-scrollhttps://chenxuan0000.github.io/vue...

轮播图3D效果--roundabout(兼容IE8)升级版

<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <style> *{ margin:0;...

小程序自定义轮播图

话不多说,上图上代码。 wxml <view bindtouchstart="touchstart" bindtouchmove="touchmove" bindtouchend="touchend"> <view animation="{{animation1}}" bindtap="scrollLeft"> <imag...

Swiper 用法

部分常用API ininialSlide: 2, //起始图片切换的索引位置(起始从0开始,默认为0) autoplay: 3000, //设置自动切换时间,单位毫秒 speed: 1000, //设置滑动速度 continuous: true, //无限循环的图片切换效果 disableScroll: true, //阻止由于触摸而滚动屏幕 stopPr...

Node.js Express博客项目实战 之 项目需求分析

项目概述:       本项目主要使用Node.js+express框架+mysql数据库完成博客系统开发 项目需求:  node 安装与运行 node 基础模块的使用 npm 使用 mysql 数据库的基本知识 项目分析: 1)前台功能分析       首页 栏目列表 轮播图展示 最新发布 热门文章 搜索功能      分类页 分类新闻 热...

swiper插件简介及用法

swiper Swiper是纯javascript打造的滑动特效插件,面向手机、平板电脑等移动终端。Swiper能实现触屏焦点图、触屏Tab切换、触屏多图切换等常用效果。Swiper开源、免费、稳定、使用简单、功能强大,是架构移动终端网站的重要选择 1.首先创建一个swiper的运行环境,需要用到的文件有swiper.min.js和swiper.min.c...