Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html lang="en">
<head>
  <title>AngularJS - UI Router - Example 1</title>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link href='https://fonts.googleapis.com/css?family=Open+Sans:400' rel='stylesheet' type='text/css'>
  

</head>
<body ng-app="DemoApp">
	
	<div ng-controller="DemoController">
		<header>
			<h1>AngularJS && UI.Router</h1>
			<h2>Example 1: Transition between state</h2>
		</header>

		<nav>
			<ul>
				<li>
					<a 	href="#" title="left" 	
						ng-class="{active:transition=='slide-left'}" 		ng-click="left()"> 
						Left
					</a>
				</li>
				<li>
					<a 	href="#" title="right" 	
						ng-class="{'active':transition=='slide-right'}" 	ng-click="right()">
						Right
					</a>
				</li>
				<li>
					<a 	href="#" title="top" 	
						ng-class="{'active':transition=='slide-top'}" 		ng-click="top()">
						Top
					</a>
				</li>
				<li>
					<a 	href="#" title="bottom" 	
						ng-class="{'active':transition=='slide-bottom'}" 	ng-click="bottom()">
						Bottom
					</a>
				</li>
			</ul>
		</nav>

		<div class="content">
			<div ui-view ng-class="transition">
				default content
			</div>
		</div>
	</div>

  <script data-require="angular.js@1.2.10" data-semver="1.2.10" src="https://code.angularjs.org/1.2.10/angular.min.js"></script>
  <script data-require="angular-animate@1.2.11" data-semver="1.2.11" src="https://code.angularjs.org/1.2.11/angular-animate.min.js"></script>
  <script src="https://angular-ui.github.io/ui-router/release/angular-ui-router.min.js"></script>
</body>
</html>
              
            
!

CSS

              
                @import "lesshat";

html, body
{
  background: #F9F7F6;
  font-family: 'Open Sans';
  font-size: 12px;
  line-height: 1.25;
}

header
{
  text-align: center;
  padding: 2em;
  color: #404D5B;

  h1
  {
    font-size: 4em;
    line-height: .2;
  }

  h2
  {
    font-size: 1.5em;
    font-weight: normal;
    .opacity(.5);
  }
}

nav
{
  text-align: center;
  ul
  {
    list-style: none;
    padding: 2em;

    li
    {
      display: inline-block;
      a
      {
        text-decoration: none;
        padding: 5px;
        font-size: 1.3em;
        border: 3px solid #F9F7F6;
        .transition(.3s);
        text-transform: uppercase;
        color: #404D5B;

        &.active
        {
          border: 3px solid #404D5B;
        }

        &:hover
        {
          background: #404D5B;
          color: #F9F7F6;
        }
      }
    }
  }
}

.content
{
   width: 100%;
   height: 370px;
   position: relative;
   margin: 20px auto;
   overflow: hidden;

   .tab 
   {
      overflow: hidden;
      padding: 1em 4em;
      height: 370px;

      font-size: 2em;
      line-height: 1.4;
   }

   .tab1
   {
      background: #34495E;
      color: #B4B4B4;
   }

   .tab2
   {
      background: #E74C3C;
      color: #fff;
   }

   .tab3
   {
      background: #bbc3c3;
      color: #404D5B;
   }

   .tab4
   {
      background: #F9F7F6;
   }
}

.slide-left.ng-enter, .slide-left.ng-leave,
.slide-right.ng-enter,.slide-right.ng-leave,
.slide-top.ng-enter,.slide-top.ng-leave,
.slide-bottom.ng-enter,.slide-bottom.ng-leave,
{
  position: absolute;
  top: 0; 
  right: 0; 
  bottom: 0; 
  left: 0;

  .transition(.3s ease-in-out);
}

// 
//  SLIDE LEFT
// 

.slide-left
{
  &.ng-enter.ng-enter-active 
  {
    .transform(translateX(0));
  }
  
  &.ng-leave 
  {
    z-index: 100;
    .transform(translateX(0));
  }
  &.ng-leave-active 
  {
    .transform(translateX(-100%));
  }
}



// 
//  SLIDE RIGHT
// 

.slide-right
{
  &.ng-enter 
  {
    .transform(translateX(-100%));
  } 

  &.ng-enter-active, 
  {
    position: absolute;
    .transform(translateX(0));
  }

  &.ng-leave-active 
  {
    .transform(translateX(100%));
  }
}


// 
//  SLIDE TOP
// 

.slide-top
{
  &.ng-enter 
  {
    .transform(translateY(-100%));
  } 

  &.ng-enter-active, 
  {
    position: absolute;
    .transform(translateY(0));
  }

  &.ng-leave-active 
  {
    .transform(translateY(100%));
  }
}


// 
//  SLIDE BOTTOM
// 

.slide-bottom
{
  &.ng-enter-active 
  {
    .transform(translateY(0));
  }

  &.ng-leave 
  {
    z-index: 100;
    .transform(translateY(0));
  }

  &.ng-leave-active
  {
    .transform(translateY(-100%));
  }
}
              
            
!

JS

              
                angular
	.module('DemoApp', ['ui.router', 'ngAnimate'])

	.config(function($stateProvider, $urlRouterProvider)
	{
		$stateProvider
			.state('tab1', {
				name: 'tab1',
				url: '/tab1',
				template: '<div class="tab tab1"><p>Caerphilly fromage cheeseburger. Goat fromage frais halloumi melted cheese cheese and biscuits macaroni cheese babybel ricotta. Roquefort croque monsieur babybel fromage frais chalk and cheese bavarian bergkase cream cheese emmental. When the cheese comes out everybody\'s happy camembert de normandie fromage frais ricotta.</p></div>'
			})

			.state('tab2', {
				name: 'tab2',
				url: '/tab2',
				template: '<div class="tab tab2"><p>Airedale hard cheese roquefort. Paneer pepper jack jarlsberg st. agur blue cheese bavarian bergkase macaroni cheese             croque monsieur cauliflower cheese. Bavarian bergkase cheesy grin port-salut taleggio stinking bishop cheese and biscuits rubber cheese blue   castello. Everyone loves.</p></div>'
			})

			.state('tab3', {
				name: 'tab3',
				url: '/tab3',
				template: '<div class="tab tab3"><p>Cheese and biscuits stinking bishop jarlsberg. Boursin melted cheese emmental cheeseburger cheese slices mozzarella cream cheese say cheese. Macaroni cheese fondue mozzarella cheese strings cheese triangles when the cheese comes out everybody\'s happy cheese on toast croque monsieur. Stinking bishop rubber cheese when the cheese comes out everybody\'s happy paneer cheesy feet.</p></div>'
			})

			.state('tab4', {
				name: 'tab4',
				url: '/tab4',
				template: '<div class="tab tab4"><p>Bocconcini hard cheese stinking bishop. Cheesecake gouda cheese and biscuits red leicester airedale cheeseburger say cheese pecorino. St. agur blue cheese cheese triangles emmental pecorino monterey jack cut the cheese emmental cheese slices. Manchego cow cheeseburger airedale who moved my cheese cottage cheese airedale feta. Parmesan.</p></div>'
			});
	})

	.controller('DemoController', function( $scope, $window, $state )
	{
		$scope.transition = 'slide-left';
		$scope.tabs = ['tab1', 'tab2', 'tab3', 'tab4'];
		$scope.currentIndex = -1;
		$scope.maxIndex = $scope.tabs.length;
		$scope.left = false;

		next();

		function next()
		{
			$scope.currentIndex = $scope.currentIndex+1 < $scope.maxIndex ? $scope.currentIndex+1 : 0;
			var name = $scope.tabs[$scope.currentIndex];
			$state.go( name );
		}

		$scope.left = function()
		{
			$scope.transition = 'slide-left';
			next();
		}

		$scope.right = function()
		{
			$scope.transition = 'slide-right';
			next();
		}

		$scope.top = function()
		{
			$scope.transition = 'slide-top';
			next();
		}

		$scope.bottom = function()
		{
			$scope.transition = 'slide-bottom';
			next();
		}
	})
;
              
            
!
999px

Console