blast icon indicating copy to clipboard operation
blast copied to clipboard

Angular directive

Open dbuezas opened this issue 10 years ago • 2 comments

It would be great to have a directive for blast :)

dbuezas avatar Nov 25 '14 17:11 dbuezas

In case someone needs it now, here is my hacky solution:

//pattern from https://amitgharat.wordpress.com/2013/02/03/an-approach-to-use-jquery-plugins-with-angularjs/
angular.module('myCoolApp')
.directive('jqBlast', function($timeout, $animate) {
  return {
    restrict: 'A',
    scope: {},
    link: function($scope, element, attrs) {
      return $timeout(function() { //http://stackoverflow.com/a/12641788/719141
        var blasted = element.blast($scope.$eval(attrs.jqBlast));
        angular.forEach(blasted, function(el) {
          $animate.addClass(el, 'animated');
        });
        element.addClass('blasted');
      });
    }
  };
});

use:

<div class="myClass" jq-blast="{delimiter: 'letter'}">{{myTextThatComesFromTheScope}}</div>
.myClass{
    opacity: 0;
}
.myClass.blasted{
    opacity: 1;
}
.myClass .animated-add{
    animation: zoomIn 1000ms;
}

.myClass .animated-add-stagger{
    animation-delay: 70ms;
}

dbuezas avatar Nov 25 '14 18:11 dbuezas

Thank you dbuezas I really appreciate the code snippet. I was having a hard time.

ghost avatar Dec 27 '14 01:12 ghost