|
1 | 1 | /* global assert suite test internalScope */ |
2 | 2 |
|
3 | | - |
4 | 3 | (function () { |
5 | 4 | suite('offsetPath', function () { |
6 | 5 | test('basicShapeCircle', function () { |
7 | | - var assertTransformInterpolation = internalScope.assertTransformInterpolation; |
8 | | - var offsetPathParse = internalScope.offsetPathParse; |
| 6 | + var assertTransformInterpolation = internalScope.assertTransformInterpolation; |
| 7 | + var offsetPathParse = internalScope.offsetPathParse; |
9 | 8 |
|
10 | | - var containerStyle = { |
| 9 | + var containerStyle = { |
11 | 10 | position: 'absolute', |
12 | 11 | height: '100px', |
13 | 12 | width: '200px' |
14 | | - }; |
| 13 | + }; |
15 | 14 |
|
16 | | - var container = document.createElement('div'); |
| 15 | + var container = document.createElement('div'); |
17 | 16 |
|
18 | | - for (var property in containerStyle) { |
| 17 | + for (var property in containerStyle) { |
19 | 18 | container.style[property] = containerStyle[property]; |
20 | | - } |
| 19 | + } |
21 | 20 |
|
22 | | - var target = document.createElement('div'); |
23 | | - container.appendChild(target); |
24 | | - document.body.appendChild(container); |
| 21 | + var target = document.createElement('div'); |
| 22 | + container.appendChild(target); |
| 23 | + document.body.appendChild(container); |
25 | 24 |
|
26 | | - var circlePathString = offsetPathParse('circle(50%)', target).path; |
27 | | - assert.equal(circlePathString, 'M 100 50 m 0,-79.06 a 79.06,79.06 0 0,1 79.06,79.06 a 79.06,79.06 0 1,1 -79.06,-79.06 z'); |
| 25 | + var circlePathString = offsetPathParse('circle(50%)', target).path; |
| 26 | + assert.equal(circlePathString, 'M 100 50 m 0,-79.06 a 79.06,79.06 0 0,1 79.06,79.06 a 79.06,79.06 0 1,1 -79.06,-79.06 z'); |
28 | 27 |
|
29 | | - circlePathString = offsetPathParse('circle(10px)', target).path; |
30 | | - assert.equal(circlePathString, 'M 100 50 m 0,-10 a 10,10 0 0,1 10,10 a 10,10 0 1,1 -10,-10 z'); |
| 28 | + circlePathString = offsetPathParse('circle(10px)', target).path; |
| 29 | + assert.equal(circlePathString, 'M 100 50 m 0,-10 a 10,10 0 0,1 10,10 a 10,10 0 1,1 -10,-10 z'); |
31 | 30 |
|
32 | | - circlePathString = offsetPathParse('circle(10px at 50%)', target).path; |
33 | | - assert.equal(circlePathString, 'M 100 50 m 0,-10 a 10,10 0 0,1 10,10 a 10,10 0 1,1 -10,-10 z'); |
| 31 | + circlePathString = offsetPathParse('circle(10px at 50%)', target).path; |
| 32 | + assert.equal(circlePathString, 'M 100 50 m 0,-10 a 10,10 0 0,1 10,10 a 10,10 0 1,1 -10,-10 z'); |
34 | 33 |
|
35 | | - circlePathString = offsetPathParse('circle(50% at 100px 200px)', target).path; |
36 | | - assert.equal(circlePathString, 'M 100 200 m 0,-79.06 a 79.06,79.06 0 0,1 79.06,79.06 a 79.06,79.06 0 1,1 -79.06,-79.06 z'); |
| 34 | + circlePathString = offsetPathParse('circle(50% at 100px 200px)', target).path; |
| 35 | + assert.equal(circlePathString, 'M 100 200 m 0,-79.06 a 79.06,79.06 0 0,1 79.06,79.06 a 79.06,79.06 0 1,1 -79.06,-79.06 z'); |
37 | 36 |
|
38 | | - circlePathString = offsetPathParse('circle(10px at 50% 50%)', target).path; |
39 | | - assert.equal(circlePathString, 'M 100 50 m 0,-10 a 10,10 0 0,1 10,10 a 10,10 0 1,1 -10,-10 z'); |
| 37 | + circlePathString = offsetPathParse('circle(10px at 50% 50%)', target).path; |
| 38 | + assert.equal(circlePathString, 'M 100 50 m 0,-10 a 10,10 0 0,1 10,10 a 10,10 0 1,1 -10,-10 z'); |
40 | 39 |
|
41 | | - assertTransformInterpolation([ |
| 40 | + assertTransformInterpolation([ |
42 | 41 | {'offsetPath': 'circle(10px at 0px 0px)', 'offsetDistance': '0%'}, |
43 | 42 | {'offsetPath': 'circle(10px at 0px 0px)', 'offsetDistance': '100%'}], |
44 | | - [ |
| 43 | + [ |
45 | 44 | {at: 0, is: 'translate3d(0px, -10px, 0px)'}, |
46 | 45 | {at: 0.25, is: 'translate3d(10px, 0px, 0px) rotate(90deg)'}, |
47 | 46 | {at: 0.5, is: 'translate3d(0px, 10px, 0px) rotate(180deg)'}, |
48 | 47 | {at: 0.75, is: 'translate3d(-10px, 0px, 0px) rotate(-90deg)'}, |
49 | 48 | {at: 1, is: 'translate3d(0px, -10px, 0px)'} |
50 | | - ] |
| 49 | + ] |
51 | 50 | ); |
52 | 51 |
|
53 | | - assertTransformInterpolation([ |
| 52 | + assertTransformInterpolation([ |
54 | 53 | {'offsetPath': 'circle(10px at 0px 0px)', 'offsetDistance': '0px'}, |
55 | 54 | {'offsetPath': 'circle(10px at 0px 0px)', 'offsetDistance': '62.83px'}], |
56 | | - [ |
| 55 | + [ |
57 | 56 | {at: 0, is: 'translate3d(0px, -10px, 0px)'}, |
58 | 57 | {at: 0.25, is: 'translate3d(10px, 0px, 0px) rotate(89.45deg)'}, |
59 | 58 | {at: 0.5, is: 'translate3d(0.01px, 10px, 0px) rotate(180deg)'}, |
60 | 59 | {at: 0.75, is: 'translate3d(-10px, 0.01px, 0px) rotate(-90deg)'}, |
61 | 60 | {at: 1, is: 'translate3d(-0.01px, -10px, 0px) rotate(-0.55deg)'} |
62 | | - ] |
| 61 | + ] |
63 | 62 | ); |
64 | 63 |
|
65 | | - assertTransformInterpolation([ |
| 64 | + assertTransformInterpolation([ |
66 | 65 | {'offsetPath': 'circle(10px at 0px 0px)', 'offsetDistance': '0%'}, |
67 | 66 | {'offsetPath': 'circle(10px at 0px 0px)', 'offsetDistance': '50%'}], |
68 | | - [ |
| 67 | + [ |
69 | 68 | {at: 0, is: 'translate3d(0px, -10px, 0px)'}, |
70 | 69 | {at: 0.5, is: 'translate3d(10px, 0px, 0px) rotate(90deg)'}, |
71 | 70 | {at: 1, is: 'translate3d(0px, 10px, 0px) rotate(180deg)'} |
72 | | - ] |
| 71 | + ] |
73 | 72 | ); |
74 | 73 |
|
75 | | - assertTransformInterpolation([ |
| 74 | + assertTransformInterpolation([ |
76 | 75 | {'offsetPath': 'circle(10px at 0px 0px)', 'offsetDistance': '0px'}, |
77 | 76 | {'offsetPath': 'circle(10px at 0px 0px)', 'offsetDistance': '31.42px'}], |
78 | | - [ |
| 77 | + [ |
79 | 78 | {at: 0, is: 'translate3d(0px, -10px, 0px)'}, |
80 | 79 | {at: 0.5, is: 'translate3d(10px, 0px, 0px) rotate(90deg)'}, |
81 | 80 | {at: 1, is: 'translate3d(0px, 10px, 0px) rotate(179.45deg)'} |
82 | | - ] |
| 81 | + ] |
83 | 82 | ); |
84 | 83 |
|
85 | | - assertTransformInterpolation([ |
| 84 | + assertTransformInterpolation([ |
86 | 85 | {'offsetPath': 'circle(10px at 100px 100px)', 'offsetDistance': '0%'}, |
87 | 86 | {'offsetPath': 'circle(10px at 100px 100px)', 'offsetDistance': '100%'}], |
88 | | - [ |
| 87 | + [ |
89 | 88 | {at: 0, is: 'translate3d(100px, 90px, 0px)'}, |
90 | 89 | {at: 0.25, is: 'translate3d(110px, 100px, 0px) rotate(90deg)'}, |
91 | 90 | {at: 0.5, is: 'translate3d(100px, 110px, 0px) rotate(180deg)'}, |
92 | 91 | {at: 0.75, is: 'translate3d(90px, 100px, 0px) rotate(-90deg)'}, |
93 | 92 | {at: 1, is: 'translate3d(100px, 90px, 0px)'} |
94 | | - ] |
| 93 | + ] |
95 | 94 | ); |
96 | | - }); |
97 | | - }); |
98 | | - })(); |
| 95 | + }); |
| 96 | + }); |
| 97 | +})(); |
0 commit comments