本来想用swiper插件的,可是需求居然说要汉字当导航栏这就没办法了,只能自己写。

directive

// 自定义指令: Home页面的轮播图
app.directive('swiperImg', ["$interval", function ($interval) {
return {
restrict: 'E',
replace: true,
scope: { imgList: "=", tabList: "=", autoplay : "="},
template: '<div class="swiper-container"><ul class="swiper-wrapper" >' +
'<li class="swiper-wrapper-items" ng-repeat="item in imgList" ng-class="{ imgActive : isSelImg(item) }"><img ng-src="{{item.src}}" /></li>' +
'</ul><ul class="swiper-pagination"><li class="pagination-item" ng-repeat="item in tabList" ng-mouseover="hoverTab($index)" ng-mouseleave="leaveTab($index)" ng-class="{ imgActive : isSelImg(item) }">{{ item.name }}</li></ul></div>',
link: function ($scope, elem, attr) {
var i = 0;
var imgInterval;
$scope.hoverTab = function (index) {
$scope.hoverImg = index;
$scope.isSelImg(index);
i = index;
$interval.cancel(imgInterval);
}
$scope.leaveTab = function (index) {
imgInterval = $interval(function () {
if (i == $scope.imgList.length) {
i = 0;
}
$scope.hoverImg = i;
$scope.isSelImg(i);
i++;
}, $scope.autoplay);
}
imgInterval = $interval(function () {
if (i > 3) {
i = 0;
}
$scope.hoverImg = i;
$scope.isSelImg(i);
i++;
}, $scope.autoplay);
$scope.isSelImg = function (item) {
return $scope.hoverImg == item.id;
}
$scope.hoverImg = i;
$scope.isSelImg(i);
}
};
}]);

CSS

.swiper-container {
margin: 0 auto;
position: relative;
overflow: hidden;
z-index:;
width: 100%;
height: 100%;
}
.swiper-wrapper{
height: 200px;
width: 100%;
}
.swiper-wrapper-items {
height: 100%;
position: absolute;
width: 100%;
opacity:;
transition: opacity .8s;
-moz-transition: opacity .8s;
-webkit-transition: opacity .8s;
-o-transition: opacity .8s;
}
.imgActive.swiper-wrapper-items {
opacity:;
}
.swiper-container img {
width: 100%;
height: 100%;
} .swiper-pagination {
display: box;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
bottom: 0 !important;
position: absolute;
left:;
right:;
text-align: center;
z-index:;
} .pagination-item:first-child {
background-color: rgba(60,141,188,0.5);
} .pagination-item:nth-child(2) {
background-color: rgba(202,64,64,0.5);
} .pagination-item:nth-child(3) {
background-color: rgba(255,134,4,0.5);
} .pagination-item:last-child {
background-color: rgba(34,172,56,0.5);
}
.imgActive.pagination-item:first-child {
background-color: rgba(60,141,188,1);
}
.imgActive.pagination-item:nth-child(2) {
background-color: rgba(202,64,64,1);
}
.imgActive.pagination-item:nth-child(3) {
background-color: rgba(255,134,4,1);
}
.imgActive.pagination-item:last-child {
background-color: rgba(34,172,56,1);
}
.pagination-item {
-webkit-box-flex:;
-moz-box-flex:;
-webkit-flex:;
-ms-flex:;
flex:;
-webkit-user-select: none; /* Chrome all / Safari all /opera15+*/
-moz-user-select: none; /* Firefox all */
-ms-user-select: none; /* IE 10+ */
user-select: none;
cursor: pointer;
color: #fff;
padding: 10px;
transition: all .8s;
-moz-transition: all .8s;
-webkit-transition: all .8s;
-o-transition: all .8s;
}

引用

<swiper-img img-list="imgList" tab-list="tabList" autoplay="autoplay"></swiper-img>

控制器

$scope.tabList = [{ id: 0, name: "开拓创新" }, { id: 1, name: "高效务实" }, { id: 2, name: "利益客户" }, { id: 3, name: "成就员工" }];
$scope.imgList = [{ id: 0, src: "@Url.Content("~/Content/images/u3.jpg")" }, { id: 1, src: "@Url.Content("~/Content/images/bg1.png")" },
{ id: 2, src: "@Url.Content("~/Content/images/bg2.png")" }, { id: 3, src: "@Url.Content("~/Content/images/bg3.png")" }];
$scope.autoplay = 5000;

tabList 是汉字导航栏

imgList 是图片链接数组

autoplay 是切换时间

效果图

好的,完成了。

angularjs1 自定义轮播图(汉字导航)的更多相关文章

  1. 【自定义轮播图】微信小程序自定义轮播图无缝滚动

    先试试效果,可以通过设置参数调整样式 微信小程序中的轮播图可以直接使用swiper组件,如下: <swiper indicator-dots="{{indicatorDots}}&qu ...

  2. 带轮播图、导航栏、商品的简单html,以及轮播图下边数字随轮播图的改变而改变

    ---恢复内容开始--- 在做这个的时候,最不会的是中间轮播图下边的数字是如何实现转变的,后来加入了jQuery就能实现了. css部分: <style type="text/css& ...

  3. vue自定义轮播图组件 swiper

    1.banner 组件 components/Banner.vue <!-- 轮播图 组件 --> <template> <div class="swiper- ...

  4. taro 自定义 轮播图组件

    1.代码 components/MySwiper/index.js /** * 轮播图组件 */ import Taro, { Component } from '@tarojs/taro'; imp ...

  5. BootStrap自定义轮播图播放速度

    $('.carousel').carousel({      interval: 3000 });

  6. 前台主页搭建、后台主页轮播图接口设计、跨域问题详解、前后端互通、后端自定义配置、git软件的初步介绍

    今日内容概要 前台主页 后台主页轮播图接口 跨域问题详解 前后端打通 后端自定义配置 git介绍和安装 内容详细 1.前台主页 Homeviwe.vue <template> <di ...

  7. swift-自定义无限轮播图

    一  前言 1.之前一直在用OC编程,最近才开始接触使用swift就发现使用OC越来越不习惯,感觉已经爱上了swift. 2.这个自定义轮播图只是对之前OC版本进行了翻译,欢迎指正. 3.我决定一步步 ...

  8. Android开发之ViewPager实现轮播图(轮播广告)效果的自定义View

    最近开发中需要做一个类似京东首页那样的广告轮播效果,于是采用ViewPager自己自定义了一个轮播图效果的View. 主要原理就是利用定时任务器定时切换ViewPager的页面. 效果图如下: 主页面 ...

  9. android ViewPager实现的轮播图广告自定义视图,网络获取图片和数据

    public class SlideShowAdView extends FrameLayout { //轮播图图片数量    private static int IMAGE_COUNT = 3;  ...

随机推荐

  1. javascript数组中的方法

    数组中的方法 今天我们来说一下,对数组进行操作的几种方法: //添加 a=[];//空数组   a[0]="我是第一个";   a[2]="我是第三个";    ...

  2. ArcGIS runtime for wpf 部署

    简介 ArcGIS runtime for wpf 是一个轻量级的产品,部署方便,甚至可以做到直接部署在U盘中,做到即插即用. 部署一般需要遵循如下几个步骤: 1. 设定部署许可 虽然ArcGIS r ...

  3. Qt 打印机支持模块

    Qt 打印支持 Qt为打印提供广泛的跨平台支持.使用每个平台上的打印系统,Qt应用程序可以打印到连接的打印机,并通过网络打印到远程打印机.Qt的打印系统还支持PDF文件生成,为基本的报告生成设施奠定了 ...

  4. python引入同一目录下的py文件

    python引入同一目录下的py文件 注意:python2和python3的包内import语法有区别,下面介绍一下python3的包内import语法 例如在admin.py文件中要引入dealco ...

  5. 微信js获取地理位置

    1.绑定域名 先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”. 备注:登录后可在“开发者中心”查看对应的接口权限. 2.引入js文件 <script type=&q ...

  6. django的项目创建简明流程

    个人理解,不妥之处请指出 创建项目:django-admin startproject user_sys 创建APP:python manage.py startapp auth 测试项目创建是否成功 ...

  7. disruptor 高并发编程 简介demo

    原文地址:http://www.cnblogs.com/qiaoyihang/p/6479994.html disruptor适用于大规模低延迟的并发场景.可用于读写操作分离.数据缓存,速度匹配(因为 ...

  8. [ Error 分析] Comparison method violates its general contract!

    public static void main(String[] args) { List<Long> ret = new ArrayList<>(); int n = 103 ...

  9. Java并发之——线程池

    一. 线程池介绍 1.1 简介 线程池是一种多线程处理形式,处理过程中将任务添加到队列,然后在创建线程后自动启动这些任务.线程池的基本思想还是一种对象池的思想,开辟一块内存空间,里面存放了众多(未死亡 ...

  10. cdoj1338郭大侠与英雄学院

    地址:http://acm.uestc.edu.cn/#/problem/show/1338 思路: 郭大侠与英雄学院 Time Limit: 6000/2000MS (Java/Others)    ...