Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
58ed62ed
Commit
58ed62ed
authored
Apr 23, 2012
by
Corey Frang
Committed by
Dave Methvin
Apr 23, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Effects: 1.8 Animation Rewrite - thanks @mikesherov and @gibson042
parent
8ad22a2b
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
618 additions
and
546 deletions
+618
-546
css.js
src/css.js
+16
-8
effects.js
src/effects.js
+537
-534
css.js
test/unit/css.js
+3
-3
effects.js
test/unit/effects.js
+62
-1
No files found.
src/css.js
View file @
58ed62ed
(
function
(
jQuery
)
{
jQuery
.
cssExpand
=
[
"Top"
,
"Right"
,
"Bottom"
,
"Left"
];
var
ralpha
=
/alpha
\([^
)
]
*
\)
/i
,
ropacity
=
/opacity=
([^
)
]
*
)
/
,
// fixed for IE9, see #8346
rupper
=
/
([
A-Z
]
|^ms
)
/g
,
rnum
=
/^
[\-
+
]?(?:\d
*
\.)?\d
+
$/i
,
rnum
split
=
/^
([\-
+
]?(?:\d
*
\.)?\d
+
)(
.*
)
$/i
,
rnumnonpx
=
/^-
?(?:\d
*
\.)?\d
+
(?!
px
)[^\d\s]
+$/i
,
rrelNum
=
/^
([\-
+
])
=
([\-
+.
\d
e
]
+
)
/
,
rmargin
=
/^margin/
,
...
...
@@ -12,7 +14,7 @@ var ralpha = /alpha\([^)]*\)/i,
cssShow
=
{
position
:
"absolute"
,
visibility
:
"hidden"
,
display
:
"block"
},
// order is important!
cssExpand
=
[
"Top"
,
"Right"
,
"Bottom"
,
"Left"
]
,
cssExpand
=
jQuery
.
cssExpand
,
cssPrefixes
=
[
"O"
,
"Webkit"
,
"Moz"
,
"ms"
],
curCSS
;
...
...
@@ -264,6 +266,13 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) {
};
}
function
setPositiveNumber
(
elem
,
value
)
{
var
matches
=
rnumsplit
.
exec
(
value
);
return
matches
?
Math
.
max
(
0
,
matches
[
1
]
)
+
(
matches
[
2
]
||
"px"
)
:
value
;
}
function
getWidthOrHeight
(
elem
,
name
,
extra
)
{
// Start with offset property, which is equivalent to the border-box value
...
...
@@ -348,11 +357,7 @@ jQuery.each([ "height", "width" ], function( i, name ) {
}
},
set
:
function
(
elem
,
value
)
{
return
rnum
.
test
(
value
)
?
value
+
"px"
:
value
;
}
set
:
setPositiveNumber
};
});
...
...
@@ -436,7 +441,6 @@ jQuery.each({
padding
:
""
,
border
:
"Width"
},
function
(
prefix
,
suffix
)
{
jQuery
.
cssHooks
[
prefix
+
suffix
]
=
{
expand
:
function
(
value
)
{
var
i
,
...
...
@@ -453,6 +457,10 @@ jQuery.each({
return
expanded
;
}
};
if
(
!
rmargin
.
test
(
prefix
)
)
{
jQuery
.
cssHooks
[
prefix
+
suffix
].
set
=
setPositiveNumber
;
}
});
})(
jQuery
);
src/effects.js
View file @
58ed62ed
This diff is collapsed.
Click to expand it.
test/unit/css.js
View file @
58ed62ed
...
...
@@ -37,13 +37,13 @@ test("css(String|Hash)", function() {
div2
.
remove
();
// handle negative numbers by
ignoring #1599, #4216
// handle negative numbers by
setting to zero #11604
jQuery
(
"#nothiddendiv"
).
css
(
{
width
:
1
,
height
:
1
}
);
var
width
=
parseFloat
(
jQuery
(
"#nothiddendiv"
).
css
(
"width"
)),
height
=
parseFloat
(
jQuery
(
"#nothiddendiv"
).
css
(
"height"
));
jQuery
(
"#nothiddendiv"
).
css
({
width
:
-
1
,
height
:
-
1
});
equal
(
parseFloat
(
jQuery
(
"#nothiddendiv"
).
css
(
"width"
)),
width
,
"Test negative width ignored
"
);
equal
(
parseFloat
(
jQuery
(
"#nothiddendiv"
).
css
(
"height"
)),
height
,
"Test negative height ignored
"
);
equal
(
parseFloat
(
jQuery
(
"#nothiddendiv"
).
css
(
"width"
)),
0
,
"Test negative width set to 0
"
);
equal
(
parseFloat
(
jQuery
(
"#nothiddendiv"
).
css
(
"height"
)),
0
,
"Test negative height set to 0
"
);
equal
(
jQuery
(
"<div style='display: none;'>"
).
css
(
"display"
),
"none"
,
"Styles on disconnected nodes"
);
...
...
test/unit/effects.js
View file @
58ed62ed
...
...
@@ -792,7 +792,7 @@ jQuery.checkOverflowDisplay = function(){
start
();
};
test
(
"jQuery.fx.prototype.cur()
"
,
6
,
function
()
{
test
(
"jQuery.fx.prototype.cur()
- <1.8 Back Compat"
,
7
,
function
()
{
var
div
=
jQuery
(
"<div></div>"
).
appendTo
(
"#qunit-fixture"
).
css
({
color
:
"#ABC"
,
border
:
"5px solid black"
,
...
...
@@ -814,6 +814,8 @@ test( "jQuery.fx.prototype.cur()", 6, function() {
// backgroundPosition actually returns 0% 0% in most browser
// this fakes a "" return
// hook now gets called twice because Tween will grab the current
// value as it is being newed
jQuery
.
cssHooks
.
backgroundPosition
=
{
get
:
function
()
{
ok
(
true
,
"hook used"
);
...
...
@@ -1387,3 +1389,62 @@ test("animate will scale margin properties individually", function() {
});
start
();
});
// Start 1.8 Animation tests
asyncTest
(
"jQuery.Animation( object, props, opts )"
,
1
,
function
()
{
var
testObject
=
{
foo
:
0
,
bar
:
1
,
width
:
100
},
testDest
=
{
foo
:
1
,
bar
:
0
,
width
:
200
};
jQuery
.
Animation
(
testObject
,
testDest
,
{
duration
:
1
})
.
done
(
function
()
{
deepEqual
(
testObject
,
testDest
,
"Animated foo and bar"
);
start
();
});
});
asyncTest
(
"Animate Option: step: function( percent, tween )"
,
1
,
function
()
{
var
counter
=
{};
jQuery
(
"#foo"
).
animate
({
prop1
:
1
,
prop2
:
2
,
prop3
:
3
},
{
duration
:
1
,
step
:
function
(
value
,
tween
)
{
calls
=
counter
[
tween
.
prop
]
=
counter
[
tween
.
prop
]
||
[];
calls
.
push
(
value
);
}
}).
queue
(
function
(
next
)
{
deepEqual
(
counter
,
{
prop1
:
[
0
,
1
],
prop2
:
[
0
,
2
],
prop3
:
[
0
,
3
]
},
"Step function was called once at 0% and once at 100% for each property"
);
next
();
start
();
});
});
asyncTest
(
"Animate callbacks have correct context"
,
2
,
function
()
{
var
foo
=
jQuery
(
"#foo"
);
foo
.
animate
({
height
:
10
},
10
,
function
()
{
equal
(
foo
[
0
],
this
,
"Complete callback after stop(true) `this` is element"
);
}).
stop
(
true
,
true
);
foo
.
animate
({
height
:
100
},
10
,
function
()
{
equal
(
foo
[
0
],
this
,
"Complete callback `this` is element"
);
start
();
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment