|
1 | 1 |
|
2 | 2 | (function() {
|
3 | 3 |
|
4 |
| - vendorPrefix + vendorPrefix = $.keyframe.getVendorPrefix(); |
| 4 | + vendorPrefix = $.keyframe.getVendorPrefix(); |
5 | 5 |
|
6 | 6 | $.keyframe = $.extend($.keyframe, {
|
7 | 7 |
|
|
10 | 10 | spriteSheet: function(opts){
|
11 | 11 |
|
12 | 12 | var defaults = {
|
13 |
| - name: '' |
| 13 | + name: '', |
14 | 14 | rows: 1,
|
15 | 15 | cols: 1,
|
16 | 16 | height: 0,
|
17 | 17 | width: 0,
|
18 | 18 | offsetX: 0,
|
19 | 19 | offsetY: 0,
|
20 |
| - count: (rows * cols), |
| 20 | + count: (opts.rows * opts.cols), |
21 | 21 | spriteWidth: (opts.width / opts.cols),
|
22 | 22 | spriteHeight: (opts.height / opts.rows),
|
23 | 23 | loop: true
|
24 | 24 | };
|
25 | 25 |
|
26 |
| - $.extend(defaults, opts); |
| 26 | + opts = $.extend(defaults, opts); |
27 | 27 |
|
28 | 28 | $.keyframe.spriteSheets[opts.name] = opts;
|
29 | 29 |
|
30 | 30 | spriteStep = 100 / opts.count;
|
31 | 31 | spriteFrames = {};
|
32 |
| - var x = opts.offsetX; |
33 |
| - var y = opts.offsetY; |
| 32 | + var x = opts.offsetX - opts.spriteWidth; |
| 33 | + var y = opts.offsetY - opts.spriteHeight; |
34 | 34 | for(var i = 0; i < opts.count; i++){
|
35 |
| - spriteFrames[(spriteStep * i) + '%'] = { |
| 35 | + spriteFrames[Math.round(spriteStep * i) + '%'] = { |
36 | 36 | 'background-position': '-' + (opts.spriteWidth + x) + 'px -' + (opts.spriteHeight + y) + 'px'
|
37 | 37 | }
|
38 | 38 | if(x >= (opts.cols * opts.spriteWidth)){
|
|
66 | 66 | }
|
67 | 67 |
|
68 | 68 | var animate = name + ' ' + time + ' steps(' + opts.count + ') ' + loops;
|
69 |
| - var existingAnimation = $(this).css('animation'); |
70 |
| - if(existingAnimation){ |
| 69 | + var existingAnimation = this.css('animation'); |
| 70 | + if(existingAnimation.split(' ')[0] != "none"){ |
71 | 71 | animate = existingAnimation + ', ' + animate;
|
72 | 72 | }
|
73 |
| - $(this).css(vendorPrefix + 'animation', animate); |
| 73 | + console.log(this); |
| 74 | + this.css(vendorPrefix + 'animation', animate); |
74 | 75 | }
|
75 | 76 | }
|
76 | 77 | }
|
|
0 commit comments