JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Raleway:200" rel="stylesheet">
<div class="container" ng-class="{'no-scroll': selected.length}" ng-app="app" ng-controller="mainCtrl">
<div class="page">
<div class="grid">
<div class="grid-item" ng-repeat="item in boxes">
<box class="box" item="item" on-select="selectBox" ng-class="{'selected': selected[0].item.name == item.name}"></box>
</div>
</div>
</div>
<div class="fullscreen-background top-up" ng-show="selected.length" ng-style="{'background-image': 'url(' + selected[0].item.image + ')'}"></div>
<div class="scroller" ng-show="selected.length">
<a class="close-button" ng-click="clearSelection()">
<i class="material-icons">close</i>
</a>
<h1>{{selected[0].item.name}}</h1>
<div big-box ng-repeat="item in selected" class="box on-top" position="item.position" selected="item.item">
<img ng-src="{{item.item.image}}" alt="" />
<div class="content">
<h2>Lorem ipsum dolor</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Maxime laborum perferendis, ullam minus. Illo ad aliquid ab magni, enim nesciunt at consequuntur dolores explicabo nisi. Dolor, reiciendis suscipit alias nemo.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellendus consequatur, sit saepe reprehenderit nisi dolorem, voluptates amet quos ab assumenda non id accusamus, dicta soluta laboriosam voluptas fuga sint deleniti. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Magnam officiis minus tenetur ex molestias qui possimus sit facilis dolorum suscipit. Cumque, aperiam inventore nobis? Veniam voluptatibus sapiente ea, voluptate dolores?</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tenetur dicta ducimus ratione reiciendis officia odit omnis distinctio, eveniet et modi fuga nisi voluptatem nihil aliquam ex pariatur possimus repudiandae vero?</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Corporis, quos ducimus nobis. Necessitatibus provident impedit, neque quia dolores? Quas, architecto id. Iure distinctio, illum eaque at quia assumenda modi saepe. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Libero soluta quisquam autem quasi ut ex ab modi. Sit soluta dicta incidunt quaerat tenetur fugiat, natus perspiciatis illo. Totam, quo, minus.</p>
</div>
</div>
</div>
</div>
@grid-padding: 10px;
@mobile-break: 600px;
@keyframes up-in {
from {opacity: 0; bottom: 0%;}
to {opacity: 1; bottom: 50%;}
}
.fill {
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
background-attachment: fixed;
}
body,
html {
height: 100%;
min-width: 100%;
min-height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
font-family: 'Raleway', sans-serif;
}
.flex-row {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-around;
}
.container {
.flex-row;
width: 100%;
min-height: 100%;
height: 100%;
overflow: auto;
background-color: white;
position: relative;
&.no-scroll {
overflow: hidden;
}
}
.page {
width: 80%;
padding: @grid-padding;
background-color: white;
}
@media (max-width: @mobile-break)
{
.page
{
width: 90%;
}
}
.grid {
.flex-row;
.grid-item {
width: 33%;
position: relative;
&:after {
content: '';
display: block;
margin-top: 100%;
}
}
@media (max-width: @mobile-break)
{
.grid-item
{
width: 50%;
}
}
}
.box {
position: absolute;
top: @grid-padding;
bottom: @grid-padding;
left: @grid-padding;
right: @grid-padding;
background-color: white;
background-size: cover;
background-repeat: no-repeat;
background-position: center top;
overflow: hidden;
cursor: pointer;
img
{
width: 100%;
transition: transform 0.6s ease;
}
&.selected {
opacity: 0;
}
&.on-top {
cursor: default;
transition: all 0.4s ease;
box-shadow: 2px 2px 19px -2px rgba(0, 0, 0, 0.44);
}
&.image-out
{
img
{
transform: translateY(-100%);
}
}
}
.content
{
position: absolute;
padding: 20px 40px;
top: 0;
right: 0;
bottom: 0;
left: 0;
opacity: 0;
transition: opacity 0.5s ease;
.show &
{
opacity: 1;
}
}
@media (max-width: @mobile-break)
{
.content
{
padding: 10px 20px;
}
}
.scroller {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
overflow-y: auto;
h1
{
color: white;
width: 100%;
margin-bottom: 30px;
position: absolute;
bottom: 50%;
text-align: center;
animation: up-in 1s ease;
}
}
.top-up.ng-hide-add,
.top-up.ng-hide-remove {
transition: 0s ease top;
}
.top-up.ng-hide-add-active,
.top-up.ng-hide-remove-active {
transition: 0.6s ease top;
}
.top-up.ng-hide-add {
top: 0;
}
.top-up.ng-hide-add.ng-hide-add-active {
top: 100%;
}
.top-up.ng-hide-remove {
top: 100%;
}
.top-up.ng-hide-remove.ng-hide-remove-active {
top: 0
}
.fullscreen-background {
overflow-y: auto;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: #333;
transition: top 0.5s ease;
.fill;
&.show {
top: 0;
}
}
.close-button {
position: fixed;
top: 20px;
right: 20px;
color: white;
cursor: pointer;
i {
font-size: 35px;
}
&:hover {
color: #ddd;
}
}
var app = angular.module('app', ['ngAnimate'])
app.controller('mainCtrl', function($scope) {
$scope.boxes = [{
name: 'Friends',
image: 'https://source.unsplash.com/uAgLGG1WBd4/900x900'
},{
name: 'Free',
image: 'https://source.unsplash.com/Cp-LUHPRpWM/900x900'
},{
name: 'Explore',
image: 'https://source.unsplash.com/7BjmDICVloE/900x900'
}, {
name: 'Vast',
image: 'https://source.unsplash.com/WLUHO9A_xik/900x900'
}, {
name: 'Playful',
image: 'https://source.unsplash.com/b2-fBVrfx0o/900x900'
}, {
name: 'Grand',
image: 'https://source.unsplash.com/Ixp4YhCKZkI/900x900'
}, {
name: 'Mist',
image: 'https://source.unsplash.com/8BmNurlVR6M/900x900'
}, {
name: 'Sea',
image: 'https://source.unsplash.com/6YqpFWWQsno/900x900'
}, {
name: 'Reach',
image: 'https://source.unsplash.com/zFnk_bTLApo/900x900'
}, {
name: 'Awe',
image: 'https://source.unsplash.com/j4PaE7E2_Ws/900x900'
}, {
name: 'Surf',
image: 'https://source.unsplash.com/uohGiEVhWiQ/900x900'
}, {
name: 'Thrill',
image: 'https://source.unsplash.com/ssrbaKvxaos/900x900'
}, ];
$scope.selected = [];
$scope.selectBox = function(item, position) {
$scope.selected = [{
item: item,
position: position
}];
$scope.$apply();
}
$scope.clearSelection = function() {
$scope.selected = [];
}
})
app.directive('box', function() {
return {
restrict: 'E',
scope: {},
bindToController: {
onSelect: "=",
item: "="
},
controllerAs: 'box',
controller: function() {
var box = this;
box.goFullscreen = function(e) {
box.onSelect(box.item, e.target.getBoundingClientRect())
}
},
link: function(scope, element) {
element.bind('click', scope.box.goFullscreen)
element.css({
'background-image': 'url(' + scope.box.item.image + ')'
})
}
}
})
app.directive('bigBox', function($timeout) {
return {
restrict: 'AE',
scope: {},
bindToController: {
position: "=",
selected: "=",
onSelect: "="
},
controllerAs: 'box',
controller: function() {
var box = this;
},
link: function(scope, element) {
var css = {}
for (var key in scope.box.position) {
css[key] = scope.box.position[key] + 'px';
}
element.css(css);
$timeout(function() {
element.css({
top: '50%',
left: '10%'
})
element.addClass('image-out');
}, 200)
$timeout(function() {
element.css({
width: '80%',
height: '100%'
})
}, 500)
$timeout(function(){
element.addClass('show');
}, 800)
}
}
})
Also see: Tab Triggers