Debian Codegraph @

tests/unit/effects/scale.js

raw symbols SCIP
1 define( [
2 "qunit",
3 "jquery",
4 "lib/helper",
5 "ui/effects/effect-scale"
6 ], function( QUnit, $, helper ) {
7 "use strict";
8
9 QUnit.module( "effect.scale: Scale", { afterEach: helper.moduleAfterEach } );
10
11 function run( position, v, h, vo, ho ) {
12 var desc = "End Position Correct: " + position + " (" + v + "," + h + ") - origin: (" + vo + "," + ho + ")";
13 QUnit.test( desc, function( assert ) {
14 var ready = assert.async();
15 assert.expect( 2 );
16 function complete() {
17 assert.close( parseInt( test.css( h ), 10 ), target[ h ], 1, "Horizontal Position Correct " + desc );
18 assert.close( parseInt( test.css( v ), 10 ), target[ v ], 1, "Vertical Position Correct " + desc );
19 ready();
20 }
21 var test = $( ".testScale" ),
22 css = {
23 position: position
24 },
25 effect = {
26 effect: "scale",
27 mode: "effect",
28 percent: 200,
29 origin: [ vo, ho ],
30 complete: complete,
31 duration: 1
32 },
33 target = {},
34 relative = position === "relative";
35
36 css[ h ] = 33;
37 css[ v ] = 33;
38 if ( h === ho ) {
39 target[ h ] = css[ h ];
40 } else if ( ho === "center" ) {
41 target[ h ] = css[ h ] - 35;
42 } else {
43 target[ h ] = css[ h ] - 70;
44 }
45 if ( v === vo ) {
46 target[ v ] = css[ v ];
47 } else if ( vo === "middle" ) {
48 target[ v ] = css[ v ] - 35;
49 } else {
50 target[ v ] = css[ v ] - 70;
51 }
52 if ( relative && h === "right" ) {
53 target[ h ] += 70;
54 }
55 if ( relative && v === "bottom" ) {
56 target[ v ] += 70;
57 }
58 test.css( css );
59 test.effect( effect );
60 } );
61 }
62
63 function suite( position ) {
64 run( position, "top", "left", "top", "left" );
65 run( position, "top", "left", "middle", "center" );
66 run( position, "top", "left", "bottom", "right" );
67
68 /* Firefox is currently not capable of supporting detection of bottom and right....
69 run( position, "bottom", "right", "top", "left" );
70 run( position, "bottom", "right", "middle", "center" );
71 run( position, "bottom", "right", "bottom", "right" );
72 */
73 }
74
75 $( function() {
76 suite( "absolute" );
77 suite( "relative" );
78 var fixedElem = $( "<div>" )
79 .css( {
80 position: "fixed",
81 top: 10
82 } )
83 .appendTo( "body" );
84 if ( fixedElem.offset().top === 10 ) {
85 suite( "fixed" );
86 }
87 } );
88
89 } );