angularjs时间轴

1、炫酷的图片是开端啊

2、前端html 代码

div class="container-fluid row">
            <timelineaxis ng-show="paramId>0">
                <timeaxis-item ng-repeat="item in items">
                    <a href="#/taxrm/edit/{{item.versionid}}" ng-class="{'active':paramId==item.versionid}">
                        <timeaxis-point></timeaxis-point>
                        <timeaxis-panel>{{item.content}}</timeaxis-panel>
                    </a>
                </timeaxis-item>
            </timelineaxis>
            <div class="timeaxis-hide" ng-show="paramId>0" timeaxis-hide ng-click="hide()"></div>
        </div>

3、angular directive

var TaxApp = angular.module('MyApp');
TaxApp.directive("timelineaxis", function () {
    return {
        restrict: 'AE',
        transclude: true,
        template: '<div class="timeaxis-warpper" ><ul class="timeaxis" ng-transclude></ul></div>'
    };
});

TaxApp.directive("timeaxisItem", function () {
    return {
        require: '^timeaxis',
        restrict: 'AE',
        transclude: true,
        template: '<li ng-class-even="\'timeaxis-inverted\'" ng-transclude ></li>'
    };
});

TaxApp.directive("timeaxisPoint", function () {
    return {
        require: '^timeaxisItem',
        restrict: 'AE',
        transclude: true,
        template: '<div  class="timeaxis-point"><span></span></div>'
    };
});

TaxApp.directive("timeaxisPanel", function () {
    return {
        require: '^timeaxis',
        restrict: 'AE',
        transclude: true,
        template: '<div class="timeaxis-panel" ng-transclude></div>'
    };
});

TaxApp.directive("timeaxisHide", function () {
    return {
        require: '^timeaxisWarpper',
        restrict: 'AE',
        transclude: true,
        template: '<span class="glyphicon glyphicon-menu-up"></span>'
    };
});

4、angular controller

angular.module('MyApp').controller('taxrmedit',function($scope,$routeParams){
	$scope.paramId = $routeParams.id;

	if ($scope.paramId > 0) {
		 $scope.timeaxis = function () {
           		 $scope.items = [{ versionid: 10, content: '2015.07.01~' }, { versionid: 9, content: '2015.05.01~2015.07.01' }, { versionid: 8, content: '2014.12.01~2015.05.01' }, { versionid: 7, content: '2014.01.01~2014.12.01' }, { versionid: 6, content: '2013.10.01~2014.01.01' }];
        	};

       		$scope.timeaxis();
	}
$scope.hide = function () {
        if (angular.element("timelineaxis").attr("style") === undefined || angular.element("timelineaxis").attr("style") != "display: none;") {
            angular.element("timelineaxis").hide();
            angular.element(".timeaxis-hide>span").removeClass("glyphicon-menu-up");
            angular.element(".timeaxis-hide>span").addClass("glyphicon-menu-down");
        } else {
            angular.element("timelineaxis").show();
            angular.element(".timeaxis-hide>span").removeClass("glyphicon-menu-down");
            angular.element(".timeaxis-hide>span").addClass("glyphicon-menu-up");
        }
    };

});

5、样式表

/*时间轴主区设置*/
.timeaxis-warpper
{
    overflow-x: auto;
    overflow-y: hidden;
    display: block;
    margin-right: 15px;
    padding-left: 15px;
    overflow-x: auto;
    overflow-y: hidden;
}
    /*时间轴箭头设置*/
    .timeaxis-warpper:before
    {
        position: relative;
        top: 63px;
        left: -15px;
        display: inline-block;
        border-top: 7px solid transparent;
        border-left: 0 solid #00ced1;
        border-right: 15px solid #00ced1;
        border-bottom: 7px solid transparent;
        content: " ";
    }

.timeaxis
{
    padding: 0;
    list-style: none;
    height: 100px;
    position: relative;
    width: 100%;
    display: inline-flex;
}

    /*时间轴线设置*/
    .timeaxis:before
    {
        top: 0;
        bottom: 0;
        position: absolute;
        content: " ";
        height: 3px;
        background-color: #00ced1;
        top: 50%;
        width: 100%;
    }
/*轴线点设置*/
.timeaxis-point
{
    width: 8px;
    height: 8px;
    top: 48px;
    margin-left: 65px;
    border-radius: 4px;
    border: 1px solid #00ced1;
    background-color: #ffffff;
    background-repeat: no-repeat;
    position: absolute;
}

    .timeaxis-point span
    {
        color: #bab9c9;
        font-size: 10px;
        padding: 0;
        margin: 0;
        position: relative;
        left: -5px;
    }

/*设置区域*/
.timeaxis li
{
    float: left;
    width: 140px;
    height: 30px;
}

a .timeaxis-panel
{
    background-color: #fff;
    float: left;
    top: 5px;
    border: 1px solid #d4d4d4;
    border-radius: 2px;
    width: 100%;
    height: 100%;
    position: relative;
    padding: 5px 5px;
    -webkit-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.175);
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.175);
}

    a .timeaxis-panel span
    {
        color: #333333;
    }

.timeaxis-panel:before
{
    position: absolute;
    bottom: -13px;
    top: auto;
    left: 57px;
    display: inline-block;
    border-top: 13px solid #ccc;
    border-left: 11px solid transparent;
    border-right: 11px solid transparent;
    border-bottom: 0px solid #ccc;
    content: " ";
}

.timeaxis-panel:after
{
    position: absolute;
    bottom: -12px;
    top: auto;
    left: 58px;
    border-top: 12px solid #fff;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 0px solid #fff;
    content: " ";
}

a.active .timeaxis-panel,
a:focus .timeaxis-panel
{
    border: 1px solid #00ced1;
    background-color: #00ced1;
}

    a.active .timeaxis-panel span,
    a:focus .timeaxis-panel span
    {
        color: #ffffff;
    }

    a.active .timeaxis-panel:before,
    a:focus .timeaxis-panel:before
    {
        position: absolute;
        bottom: -13px;
        top: auto;
        left: 57px;
        display: inline-block;
        border-top: 13px solid #00ced1;
        border-left: 11px solid transparent;
        border-right: 11px solid transparent;
        border-bottom: 0px solid #00ced1;
        content: " ";
    }

a.active .timeaxis-panel:after,
a:focus .timeaxis-panel:after
{
    position: absolute;
    bottom: -12px;
    top: auto;
    left: 58px;
    border-top: 12px solid #00ced1;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 0px solid #00ced1;
    content: " ";
}

a.active .timeaxis-point
{
    width: 8px;
    height: 8px;
    top: 48px;
    margin-left: 65px;
    border-radius: 4px;
    border: 2px solid #ffffff;
    background-color: #00ced1;
    background-repeat: no-repeat;
    position: absolute;
}

.timeaxis-inverted .timeaxis-panel
{
    top: 67px;
}

    .timeaxis-inverted .timeaxis-panel:before
    {
        position: absolute;
        bottom: auto;
        top: -12px;
        left: 57px;
        display: inline-block;
        border-top: 0px solid #ccc;
        border-left: 11px solid transparent;
        border-right: 11px solid transparent;
        border-bottom: 12px solid #ccc;
        content: " ";
    }

    .timeaxis-inverted .timeaxis-panel:after
    {
        position: absolute;
        bottom: auto;
        top: -11px;
        left: 58px;
        border-top: 0px solid #fff;
        border-left: 10px solid transparent;
        border-right: 10px solid transparent;
        border-bottom: 11px solid #fff;
        content: " ";
    }

    .timeaxis-inverted a.active .timeaxis-panel:before,
    .timeaxis-inverted a:focus .timeaxis-panel:before
    {
        position: absolute;
        bottom: auto;
        top: -12px;
        left: 57px;
        display: inline-block;
        border-top: 0px solid #00ced1;
        border-left: 11px solid transparent;
        border-right: 11px solid transparent;
        border-bottom: 12px solid #00ced1;
        content: " ";
    }

    .timeaxis-inverted a.active .timeaxis-panel:after,
    .timeaxis-inverted a:focus .timeaxis-panel:after
    {
        position: absolute;
        bottom: auto;
        top: -11px;
        left: 58px;
        display: inline-block;
        border-top: 0px solid #00ced1;
        border-left: 10px solid transparent;
        border-right: 10px solid transparent;
        border-bottom: 11px solid #00ced1;
        content: " ";
    }

    .timeaxis-hide {
        width: 100%;
        padding-left: 50%;
        height: 15px;
        background-color: #00ced1;
        color: #ffffff;
        position: relative;
        display: inline-block;
    }

完活!!!

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-10-14 00:34:14

angularjs时间轴的相关文章

AngularJS时间轴指令

是基于ion.rangeSlider.js,主要代码如下: <link rel="stylesheet" type="text/css" href="/css/slider/normalize.css"/> <link rel="stylesheet" type="text/css" href="/css/slider/ion.rangeSlider.css"/>

时间轴

在前端网看到个时间轴的效果,故简单模范了个. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> body{margin: 50px;} .container{margin-left: 30%;l

jQuery时间轴插件:jQuery Timelinr

前言 这是一款可用于展示历史和计划的时间轴插件,尤其比较适合一些网站展示发展历程.大事件等场景.该插件基于jQuery,可以滑动切换.水平和垂直滚动.支持键盘方向键.经过扩展后可以支持鼠标滚轮事件. HTML 我们在body中建立一个div#timeline作为展示区,#dates为时间轴,示例中我们用年份作为主轴,#issues作为内容展示区,即展示对应主轴点年份的内容,注意id对应上. <div id="timeline"> <ul id="dates&

Android 时间轴

效果图: 数据是随便填的,显得有点乱,但是不影响效果.实现方面主要是用ListView来实现,主要是根据ListView的item位置与上一条数据进行比较,来控制时间的显示隐藏效果.思路很简单,下面看代码实现: 首先是页面的整体布局,很简单,就一个ListView: res/layout/activity_main.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:and

android 简易时间轴(实质是ListView)

ListView的应用 1.在很多时候是要用到时间轴的,有些处理的时间轴比较复杂,这里就给出一个比较简单的时间轴,其实就是ListView里面的Item的设计. 直接上代码: ListView,item的xml文件-->time_item.xml 1 <?xml version="1.0" encoding="utf-8"?> 2 <RelativeLayout xmlns:android="http://schemas.andro

Jquery实现的几款漂亮的时间轴

引言 最近项目中使用了很多前端的东西,对于我一个做后台开发的人员,这是一个很好的锻炼的机会.经过这段时间的学习,感觉前端的东西太多了,太强大了,做出来的东西太炫酷了.现在有很多开源的前端框架,做的都非常的漂亮,h5发展了这么多年了,改变了互联网行业啊!下面给大家介绍几款漂亮的时间轴,也许大家以后工作中会用到. 一.纵向折叠时间轴 1.js文件(jQuery.js或者jQuery.min.js) 2.CSS文件   3.HTML代码   4.运行效果: 二.纵向鼠标滑动时间轴 1.js文件(jqu

JS时间轴效果(类似于qq空间时间轴效果)

2013-11-04 23:51 by 空智, 4041 阅读, 15 评论, 收藏, 编辑 在上一家公司写了一个时间轴效果,今天整理了下,感觉有必要写一篇博客出来 给大家分享分享 当然代码还有很多不足的地方,希望大家多指点指点下,此效果类似于QQ空间或者人人网空间时间轴效果,当时也是为了需求 研究了下qq空间逻辑(当然JS代码压缩了肯定看不到的),只是当时研究了下他们HTML结构和css结构,所以仿照他们那种逻辑自己也写了一个出来.先来看看是个什么样的吧!如下图所示: 需求分析:左侧是一个时间

时光轴 时间轴 效果

要实现类似QQ空间那样时光轴 时间轴效果 如图 ==================== 分析:左边 ul的border-left实现,这样会出现底部的 余出的线条,不美观, 所以考虑li的border-left实现. li的padding-bottom撑开上下间距 h4标题的:before实现圆圈,定位到左边. 圆圈的实现使用绝对定位实现,注意下UL和LI实现方式下的,圆圈定位位置. =========Ul实现边框======= .money-process .process-list { w

DevExpress之ChartControl实现时间轴实例 z

using System; using System.Data; using System.Windows.Forms; using DevExpress.XtraCharts; namespace DevExpressChart { public partial class winDateTime : Form { public winDateTime() { InitializeComponent(); } private void winDateTime_Load(object sende