Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ add another resource


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


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.


Save Automatically?

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 ng-app="example">
	<meta charset="utf-8">
	<title>Elastic header</title>
	<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
	<link href="//" rel="stylesheet">
	<script src="//"></script>

	<ion-header-bar class="bar-positive">
		<div class="buttons">
			<button class="button button-icon ion-navicon"></button>
		<h1 class="title">Elastic header</h1>
	<ion-content elastic-header="example-elastic-header" overflow-scroll="false">
		<div id="example-elastic-header" class="background-image"></div>
		<div class="content">
			<div class="padding">
				<h1>Elastic header</h1>
				<p>An Ionic/Angular directive for elastic headers. This implementation causes no browser repaints with silky smooth 60fps as a result.</p>
			<div class="list">
				<div class="item">1</div>
				<div class="item">2</div>
				<div class="item">3</div>
				<div class="item">4</div>
				<div class="item">5</div>
				<div class="item">6</div>
				<div class="item">7</div>
				<div class="item">8</div>
				<div class="item">9</div>
				<div class="item">10</div>
				<div class="item">12</div>
				<div class="item">13</div>
				<div class="item">14</div>
				<div class="item">15</div>


                .background-image {
	/* In this example we are using a background-image. But the header element could be anything. */
	background-image: url(;
	background-size: cover;
	background-position: center;
	/* The header must have a height: */
	height: 50vw;

.content {
	/* Content after the elastic header need a background-color to cover the elastic header. */
	background-color: white;

body {
	cursor: url(''), auto;


                angular.module('example', ['ionic'])

.directive('elasticHeader', function() {
	return {
		restrict: 'A',
		link: function(scope, scroller, attr) {
			var header = document.getElementById(attr.elasticHeader);
			var headerHeight = header.clientHeight;
			var translateAmt, scaleAmt, scrollTop, lastScrollTop;
			// Update header height on resize:
			window.addEventListener('resize', function() {
				headerHeight = header.clientHeight;
			}, false);

			scroller.bind('scroll', function(event) {
				// Different object depending if native scrolling is used or not (overflow-scroll):
				if (event.detail) {
					scrollTop = event.detail.scrollTop;
				} else if ( {
					scrollTop =;
				if (scrollTop !== lastScrollTop) {
					lastScrollTop = scrollTop;
					if (scrollTop >= 0) {
						// Scrolling up. Header should shrink:
						translateAmt = scrollTop / 2;
						scaleAmt = 1;
					} else {
						// Scrolling down. Header should expand:
						translateAmt = scrollTop / 2;
						scaleAmt = -scrollTop / headerHeight + 1;

					// Update header with new position/size:[ionic.CSS.TRANSFORM] = 'translate3d(0,'+translateAmt+'px,0) scale('+scaleAmt+','+scaleAmt+')';