你能告诉我如何以角度切换行。换句话说,我做了一个简单的折叠行示例项目,当用户点击与 Accordion 相同的行时,它会扩展。所以我的问题是,当我点击第一行它打开或扩展第三行为什么?只有第一行会扩展..我们可以添加一些线性过渡,因为它看起来像向上滑动并向下滑动。
点击第一行,展开第三行为什么?
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title>Ionic Swipe Down</title>
<link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
<script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
<script src="http://code.ionicframework.com/contrib/ionic-contrib-swipecards/ionic.swipecards.js?v=5"></script>
<script src="script.js"></script>
</head>
<style>
.bg {
background: lightgray;
position: relative;
}
.ptag {
position: absolute;
top:0;
left:0;
width: 7%;
border: 1px solid red;
height: 100%;
background: lightblue;
color: white;
}
.circle{
width: 50px;
height: 50px;
float: right;
border-radius: 100%;
background: green;
margin-top: -7%;
line-height: 50px;
text-align: center;
color:black!important;
}
</style>
<body ng-app="app">
<div ng-controller="apptes">
<div class="list card">
<div class="item item-avatar bg" ng-click="clickrow()" ng-repeat="n in obj">
<p class="ptag">P</p>
<h2>{{n.number}}</h2>
<p>{{n.name}}</p>
<p class="circle">650</p>
</div>
<div ng-show="toogle_item">
<div class="item item-body" >
<p>
This is a "Facebook" styled Card. The header is created from a Thumbnail List item,
the content is from a card-body consisting of an image and paragraph text. The footer
consists of tabs, icons aligned left, within the card-footer.
</p>
<p>
<a href="#" class="subdued">1 Like</a>
<a href="#" class="subdued">5 Comments</a>
</p>
</div>
<div class="item tabs tabs-secondary tabs-icon-left">
<a class="tab-item" href="#">
<i class="icon ion-thumbsup"></i>
Like
</a>
<a class="tab-item" href="#">
<i class="icon ion-chatbox"></i>
Comment
</a>
<a class="tab-item" href="#">
<i class="icon ion-share"></i>
Share
</a>
</div>
</div>
</div>
</div>
</body>
</html>
我们可以添加滑动并以慢动作滑动吗?
答案 0 :(得分:2)
这是你想要的,或者至少是一个起始布局:
HTML:
<html ng-app="ionicApp">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Ionic Accordion</title>
<link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
<script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
</head>
<body ng-controller="MyCtrl">
<ion-header-bar class="bar-positive">
<h1 class="title">Accordion List</h1>
</ion-header-bar>
<ion-content>
<ion-list>
<div ng-repeat="group in groups">
<ion-item class="item-stable"
ng-click="toggleGroup(group)"
ng-class="{active: isGroupShown(group)}">
<i class="icon" ng-class="isGroupShown(group) ? 'ion-minus' : 'ion-plus'"></i>
Group {{group.name}}
</ion-item>
<ion-item class="item-accordion"
ng-repeat="item in group.items"
ng-show="isGroupShown(group)">
{{item}}
</ion-item>
</div>
</ion-list>
</ion-content>
</body>
</html>
JS:
angular.module('ionicApp', ['ionic'])
.controller('MyCtrl', function($scope) {
$scope.groups = [];
for (var i=0; i<10; i++) {
$scope.groups[i] = {
name: i,
items: []
};
for (var j=0; j<3; j++) {
$scope.groups[i].items.push(i + '-' + j);
}
}
/*
* if given group is the selected group, deselect it
* else, select the given group
*/
$scope.toggleGroup = function(group) {
if ($scope.isGroupShown(group)) {
$scope.shownGroup = null;
} else {
$scope.shownGroup = group;
}
};
$scope.isGroupShown = function(group) {
return $scope.shownGroup === group;
};
});
CSS:
body {
cursor: url('http://ionicframework.com/img/finger.png'), auto;
}
/*
* http://docs.angularjs.org/api/ng/directive/ngShow#usage_animations
*/
.list .item.item-accordion {
line-height: 38px;
padding-top: 0;
padding-bottom: 0;
transition: 0.09s all linear;
}
.list .item.item-accordion.ng-hide {
line-height: 0px;
}
.list .item.item-accordion.ng-hide-add,
.list .item.item-accordion.ng-hide-remove {
display: block !important;
}