<html ng-app="angular-flippy-demo">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<div class="container">
<h1>angular-flippy Demo Page</h1>
<p>
Please refer to the <a href="https://github.com/zwacky/angular-flippy">README.md</a> for instructions on how to use angular-flippy.
</p>
<br><br><br><br><br><br>
<div class="col-sm-12" ng-repeat="item in [1]">
<h2>Item #{{$index+1}}</h2>
<flippy
class="fancy"
flip="['click']"
flip-back="['click']"
duration="800"
timing-function="ease-in-out">
<flippy-front>
<img src="http://placehold.it/300x300&text=Im the front" alt="the front" />
</flippy-front>
<flippy-back>
<img src="http://placehold.it/300x300&text=Aaaaaand the back" alt="the back" />
</flippy-back>
</flippy>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>angular-flippy Demo</title>
</head>
<body>
</body>
</html>
flippy {
float: left;
perspective: 600px;
perspective: 600px;
perspective: none;
}
flippy flippy-front,
flippy flippy-back {
position: absolute;
width: inherit;
height: inherit;
transform-style: preserve-3d;
transform-style: preserve-3d;
backface-visibility: hidden;
backface-visibility: hidden;
}
flippy flippy-front {
z-index: 900;
transform: rotate3d(0, 0, 0, 0deg);
transform: rotate3d(0, 0, 0, 0deg);
transform: rotateY(0deg);
}
flippy flippy-back {
z-index: 800;
transform: rotate3d(0, 1, 0, -180deg);
transform: rotate3d(0, 1, 0, -180deg);
transform: rotateY(180deg);
}
flippy.flipped flippy-front {
z-index: 900;
transform: rotate3d(0, 1, 0, 180deg);
transform: rotate3d(0, 1, 0, 180deg);
transform: rotateY(180deg);
}
flippy.flipped flippy-back {
z-index: 1000;
transform: rotate3d(0, 0, 0, 0deg);
transform: rotate3d(0, 0, 0, 0deg);
transform: rotateY(0deg);
}
flippy.fancy {
float: left;
margin: 0 10px 10px 0;
position: relative;
font-size: .8em;
cursor: pointer;
width: 250px;
height: 250px;
}
flippy.fancy img {
height: 100%;
width: 100%;
}
flippy.fancy flippy-front {
float: none;
position: absolute;
top: 0;
left: 0;
z-index: 900;
width: inherit;
height: inherit;
border: 1px solid #ccc;
background: white;
text-align: center;
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.9);
}
flippy.fancy flippy-front.flipped {
border-color: #eee;
/*background: #333;*/
box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
}
flippy.fancy flippy-back {
float: none;
position: absolute;
top: 0;
left: 0;
z-index: 800;
width: inherit;
height: inherit;
border: 1px solid #ccc;
background: white;
text-align: center;
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.9);
}
flippy.fancy flippy-back.flipped {
/*background: #80868d;*/
box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
}
/**
* handles the behaviour of flipping card.
*/
angular.module('angular-flippy', []).directive('flippy', function () {
return {
restrict: 'E',
scope: {
flip: '=',
flipBack: '=',
duration: '@',
timingFunction: '@'
},
link: function link($scope, $elem, $attrs) {
var CUSTOM_PREFIX = 'custom:';
var state = {
flipped: false
};
var options = {
duration: 400,
timingFunction: 'ease-in-out'
};
// assign new options
angular.forEach(['duration', 'timingFunction'], function (item) {
options[item] = $scope.item ? $scope.item : options[item];
});
angular.forEach({ flip: flip, flipBack: flipBack }, function (flipFunc, evt) {
angular.forEach($scope[evt], function (eventName) {
if (eventName.indexOf(CUSTOM_PREFIX) === -1) {
// directly register event listener to avoid having to start off angular's digest cycle
angular.element($elem)[0].addEventListener(eventName, flipFunc);
} else {
$scope.$on(eventName.substr(eventName.indexOf(CUSTOM_PREFIX)), flipFunc);
}
});
});
// set flip duration
angular.forEach(['flippy-front', 'flippy-back'], function (name) {
var el = $elem.find(name);
if (el.length == 1) {
angular.forEach(['', '-ms-', '-webkit-'], function (prefix) {
angular.element(el[0]).css(prefix + 'transition', 'all ' + options.duration / 1000 + 's ' + options.timingFunction);
});
}
});
/**
* flips the card.
* will be ignored, if the state is already the same as the target state.
*
* @param boolean isBack
*/
function _flip() {
var isBack = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0];
if (!isBack && !state.flipped || isBack && state.flipped) {
// to avoid toggling it right back if flip-back is the same event
setTimeout(function () {
$elem.toggleClass('flipped');
state.flipped = !state.flipped;
}, 0);
}
}
function flip() {
_flip();
}
function flipBack() {
_flip(true);
}
}
};
});
angular.module('angular-flippy-demo', [
'angular-flippy'
]);
Output
This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account
Dismiss xKeyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |