mirror of
https://github.com/ysoftdevs/pf2015.git
synced 2026-01-11 14:30:52 +01:00
35 lines
899 B
JavaScript
35 lines
899 B
JavaScript
/**
|
|
* handles the behaviour of flipping card.
|
|
* Soure: https://github.com/zwacky/angular-flippy
|
|
*/
|
|
angular.module('angular-flippy', [])
|
|
.directive('flippy', function() {
|
|
return {
|
|
restrict: 'EA',
|
|
link: function($scope, $elem, $attrs) {
|
|
|
|
var options = {
|
|
flipDuration: ($attrs.flipDuration) ? $attrs.flipDuration : 400,
|
|
timingFunction: 'ease-in-out',
|
|
};
|
|
|
|
// setting flip options
|
|
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.flipDuration/1000 + 's ' + options.timingFunction);
|
|
});
|
|
}
|
|
});
|
|
|
|
/**
|
|
* behaviour for flipping effect.
|
|
*/
|
|
$scope.flip = function() {
|
|
$elem.toggleClass('flipped');
|
|
}
|
|
|
|
}
|
|
};
|
|
}); |