carousel

时间:2022-04-05 02:58:21
<!DOCTYPE html>
<html lang="en" ng-app="mainApp">
<head>
<meta charset="utf-8">
<!-- add styles -->
<link href="css/style.css" rel="stylesheet" type="text/css" />
<!-- add javascripts -->
<!-- <script src="js/jquery-2.1.3.min.js"></script> 不需要 -->
<script src="js/angular.min.js"></script>
<script src="js/angular-animate.min.js"></script>
<script src="js/angular-touch.min.js"></script>
<script src="js/app.js"></script>
<title>carousel</title>
</head>
<body ng-controller="MainCtrl">
<header>
<a href="http://www.script-tutorials.com/demos/366/index.html" class="logo">
<!-- <img src="data:images/logo.png" /> -->
</a>
</header> <!-- slider container -->
<div class="container slider"> <!-- enumerate all photos -->
<img ng-repeat="photo in photos" class="slide" ng-swipe-right="showPrev()" ng-swipe-left="showNext()" ng-show="isActive($index)" ng-src="{{photo.src}}" /> <!-- prev / next controls -->
<a class="arrow prev" href="#" ng-click="showPrev()"></a>
<a class="arrow next" href="#" ng-click="showNext()"></a> <!-- extra navigation controls -->
<ul class="nav">
<li ng-repeat="photo in photos" ng-class="{'active':isActive($index)}">
<img ng-src="{{photo.src}}" alt="{{photo.desc}}" title="{{photo.desc}}" ng-click="showPhoto($index);" />
</li>
</ul> </div>
</body>
</html>
*{margin:; padding:; border: none;}
.arrow{cursor: pointer; display: block; height: 64px; margin-top: -35px; outline: medium none; position: absolute; top: 50%; width: 64px; z-index:;}
.arrow.prev{/*background-image: url("../images/prev.png");*/ left: 20px; opacity: 0.2; transition: all 0.2s linear 0s;}
.arrow.next{/*background-image: url("../images/next.png");*/ opacity: 0.2; right: 20px; transition: all 0.2s linear 0s;}
.arrow.prev:hover{opacity:;}
.arrow.next:hover{opacity:;}
.nav{bottom: -4px; display: block; height: 48px; left:; margin: 0 auto; padding: 1em 0 0.8em; position: absolute; right:; text-align: center; width: 100%; z-index:;}
.nav li{border: 5px solid #AAAAAA; border-radius: 5px; cursor: pointer; display: inline-block; height: 30px; margin: 0 8px; position: relative; width: 50px;}
.nav li.active{border: 5px solid #FFFFFF;}
.nav li img{width: 100%;}
.slider{border: 15px solid #FFFFFF; border-radius: 5px; height: 500px; margin: 20px auto; position: relative; width: 800px; -webkit-perspective: 1000px; -moz-perspective: 1000px; -ms-perspective: 1000px; -o-perspective: 1000px; perspective: 1000px; -webkit-transform-style: preserve-3d; -moz-transform-style: preserve-3d; -ms-transform-style: preserve-3d; -o-transform-style: preserve-3d; transform-style: preserve-3d;}
.slide{position: absolute; top:; left:;}
.slide.ng-hide-add{opacity:; -webkit-transition:1s linear all; -moz-transition:1s linear all; -o-transition:1s linear all; transition:1s linear all; -webkit-transform: rotateX(50deg) rotateY(30deg); -moz-transform: rotateX(50deg) rotateY(30deg); -ms-transform: rotateX(50deg) rotateY(30deg); -o-transform: rotateX(50deg) rotateY(30deg); transform: rotateX(50deg) rotateY(30deg); -webkit-transform-origin: right top 0; -moz-transform-origin: right top 0; -ms-transform-origin: right top 0; -o-transform-origin: right top 0; transform-origin: right top 0;}
.slide.ng-hide-add.ng-hide-add-active{opacity:;}
.slide.ng-hide-remove{-webkit-transition:1s linear all; -moz-transition:1s linear all; -o-transition:1s linear all; transition:1s linear all; display:block!important; opacity:;}
.slide, .slide.ng-hide-remove.ng-hide-remove-active{opacity:;}
var mainApp = angular.module('mainApp', ['ngAnimate', 'ngTouch']);

mainApp.controller('MainCtrl', function ($scope) {
// Set of Photos
$scope.photos = [
{src: '/carouseldemo/images/1.jpg', desc: 'Image 01'},
{src: '/carouseldemo/images/2.jpg', desc: 'Image 02'},
{src: '/carouseldemo/images/3.jpg', desc: 'Image 03'},
{src: '/carouseldemo/images/4.jpg', desc: 'Image 04'},
{src: '/carouseldemo/images/5.jpg', desc: 'Image 05'},
{src: '/carouseldemo/images/6.jpg', desc: 'Image 06'}
]; // initial image index
$scope._Index = 0; // if a current image is the same as requested image
$scope.isActive = function (index) {
return $scope._Index === index;
}; // show prev image
$scope.showPrev = function () {
$scope._Index = ($scope._Index > 0) ? --$scope._Index : $scope.photos.length - 1;
}; // show next image
$scope.showNext = function () {
$scope._Index = ($scope._Index < $scope.photos.length - 1) ? ++$scope._Index : 0;
}; // show a certain image
$scope.showPhoto = function (index) {
$scope._Index = index;
};
});

转载请备注。