Created
December 9, 2013 01:15
-
-
Save fcfowler/7866046 to your computer and use it in GitHub Desktop.
Non gif loading directive using spin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.directive('spinner', ['$window', function ($window) { | |
return { | |
scope: true, | |
link: function (scope, element, attr) { | |
scope.spinner = null; | |
function stopSpinner() { | |
if (scope.spinner) { | |
scope.spinner.stop(); | |
scope.spinner = null; | |
} | |
} | |
scope.$watch(attr.spinner, function (options) { | |
stopSpinner(); | |
scope.spinner = new $window.Spinner(options); | |
scope.spinner.spin(element[0]); | |
}, true); | |
} | |
}; | |
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<span spinner="{radius:5, width:2, length: 4, color: '#fff'}"></span> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment