forked from simonexmachina/ember-spin.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathx-spinner.js
59 lines (55 loc) · 2.24 KB
/
x-spinner.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* An Ember.js component for displaying a spinning loading indicator using spin.js.
*
* Implementation is Eric Berry's (@cavneb), and I've just created the bower module.
*
* You must nclude this file after you define your `App = Ember.Application.create()`.
* See [this discussion](http://discuss.emberjs.com/t/combining-component-logic-and-template-together-in-single-file/2879/10)
* for a discussion of ways to improve this.
*
* @see http://fgnass.github.io/spin.js/ for usage info
*/
XSpinnerComponent = Ember.Component.extend({
lines : 12, // The number of lines to draw
length : 6, // The length of each line
width : 2, // The line thickness
radius : 4, // The radius of the inner circle
corners : 1, // Corner roundness (0..1)
rotate : 0, // The rotation offset
direction: 1, // 1: clockwise, -1: counterclockwise
color : '#000', // #rgb or #rrggbb or array of colors
speed : 1, // Rounds per second
trail : 60, // Afterglow percentage
shadow : false, // Whether to render a shadow
hwaccel : false, // Whether to use hardware acceleration
className: 'spinner', // The CSS class to assign to the spinner
zIndex : 2e9, // The z-index (defaults to 2000000000)
top : 'auto', // Top position relative to parent in px
left : 'auto', // Left position relative to parent in px
showSpinner: function() {
var target = this.get('element');
this.spinner = new Spinner({
lines : this.get('lines'),
length : this.get('length'),
width : this.get('width'),
radius : this.get('radius'),
corners : this.get('corners'),
rotate : this.get('rotate'),
direction: this.get('direction'),
color : this.get('color'),
speed : this.get('speed'),
trail : this.get('trail'),
shadow : this.get('shadow'),
hwaccel : this.get('hwaccel'),
className: this.get('className'),
zIndex : this.get('zIndex'),
top : this.get('top'),
left : this.get('left')
});
this.spinner.spin(target);
}.on('didInsertElement'),
teardown: function() {
this.spinner.stop();
}.on('willDestroyElement')
});
Ember.Handlebars.helper('x-spinner', XSpinnerComponent);