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
1793eab3
Commit
1793eab3
authored
Jun 26, 2012
by
Richard Gibson
Committed by
Dave Methvin
Jul 06, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #11971: force numeric animation start to be numeric, closes gh-836.
parent
86b775d0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
11 deletions
+47
-11
effects.js
src/effects.js
+7
-7
testsuite.css
test/data/testsuite.css
+4
-1
effects.js
test/unit/effects.js
+36
-3
No files found.
src/effects.js
View file @
1793eab3
var
fxNow
,
timerId
,
var
fxNow
,
timerId
,
rfxtypes
=
/^
(?:
toggle|show|hide
)
$/
,
rfxtypes
=
/^
(?:
toggle|show|hide
)
$/
,
rfxnum
=
/^
(
[
+
\-]
=
)?([\d
+.
\-]
+
)([
a-z%
]
*
)
$/i
,
rfxnum
=
/^
(
?:([\-
+
])
=
)?([\d
+.
\-]
+
)([
a-z%
]
*
)
$/i
,
rrun
=
/queueHooks$/
,
rrun
=
/queueHooks$/
,
animationPrefilters
=
[
defaultPrefilter
],
animationPrefilters
=
[
defaultPrefilter
],
tweeners
=
{
tweeners
=
{
...
@@ -8,9 +8,9 @@ var fxNow, timerId,
...
@@ -8,9 +8,9 @@ var fxNow, timerId,
var
end
,
unit
,
prevScale
,
var
end
,
unit
,
prevScale
,
tween
=
this
.
createTween
(
prop
,
value
),
tween
=
this
.
createTween
(
prop
,
value
),
parts
=
rfxnum
.
exec
(
value
),
parts
=
rfxnum
.
exec
(
value
),
star
t
=
tween
.
cur
(),
targe
t
=
tween
.
cur
(),
s
cale
=
1
,
s
tart
=
+
target
||
0
,
target
=
start
;
scale
=
1
;
if
(
parts
)
{
if
(
parts
)
{
end
=
+
parts
[
2
];
end
=
+
parts
[
2
];
...
@@ -21,7 +21,7 @@ var fxNow, timerId,
...
@@ -21,7 +21,7 @@ var fxNow, timerId,
// Iteratively approximate from a nonzero starting point
// Iteratively approximate from a nonzero starting point
// Prefer the current property, because this process will be trivial if it uses the same units
// Prefer the current property, because this process will be trivial if it uses the same units
// Fallback to end or a simple constant
// Fallback to end or a simple constant
start
=
parseFloat
(
jQuery
.
css
(
tween
.
elem
,
prop
)
)
||
end
||
1
;
start
=
jQuery
.
css
(
tween
.
elem
,
prop
,
true
)
||
end
||
1
;
do
{
do
{
// If previous iteration zeroed out, double until we get *something*
// If previous iteration zeroed out, double until we get *something*
...
@@ -35,14 +35,14 @@ var fxNow, timerId,
...
@@ -35,14 +35,14 @@ var fxNow, timerId,
// Update scale, tolerating zeroes from tween.cur()
// Update scale, tolerating zeroes from tween.cur()
scale
=
tween
.
cur
()
/
target
;
scale
=
tween
.
cur
()
/
target
;
// Stop looping if
scale is unchanged or we've hit the mark
// Stop looping if
we've hit the mark or scale is unchanged
}
while
(
scale
!==
1
&&
scale
!==
prevScale
);
}
while
(
scale
!==
1
&&
scale
!==
prevScale
);
}
}
tween
.
unit
=
unit
;
tween
.
unit
=
unit
;
tween
.
start
=
start
;
tween
.
start
=
start
;
// If a +=/-= token was provided, we're doing a relative animation
// If a +=/-= token was provided, we're doing a relative animation
tween
.
end
=
parts
[
1
]
?
start
+
end
*
(
parts
[
1
]
===
"-="
?
-
1
:
1
)
:
end
;
tween
.
end
=
parts
[
1
]
?
start
+
(
parts
[
1
]
+
1
)
*
end
:
end
;
}
}
return
tween
;
return
tween
;
}]
}]
...
...
test/data/testsuite.css
View file @
1793eab3
...
@@ -126,3 +126,6 @@ body, div { background: url(http://static.jquery.com/files/rocker/images/logo_jq
...
@@ -126,3 +126,6 @@ body, div { background: url(http://static.jquery.com/files/rocker/images/logo_jq
/* #10501 */
/* #10501 */
section
{
background
:
#f0f
;
display
:
block
;
}
section
{
background
:
#f0f
;
display
:
block
;
}
/* #11971 */
#foo
{
background
:
url(data/1x1.jpg)
right
bottom
no-repeat
;
}
test/unit/effects.js
View file @
1793eab3
...
@@ -1677,13 +1677,40 @@ asyncTest( "animate does not change start value for non-px animation (#7109)", 1
...
@@ -1677,13 +1677,40 @@ asyncTest( "animate does not change start value for non-px animation (#7109)", 1
});
});
});
});
asyncTest
(
"Animation callbacks (#11797)"
,
12
,
function
()
{
asyncTest
(
"non-px animation handles non-numeric start (#11971)"
,
2
,
function
()
{
var
foo
=
jQuery
(
"#foo"
),
initial
=
foo
.
css
(
"backgroundPositionX"
);
foo
.
animate
({
backgroundPositionX
:
"42%"
},
{
duration
:
1
,
progress
:
function
(
anim
,
percent
)
{
if
(
percent
)
{
return
;
}
if
(
parseFloat
(
initial
)
)
{
equal
(
jQuery
.
style
(
this
,
"backgroundPositionX"
),
initial
,
"Numeric start preserved"
);
}
else
{
equal
(
jQuery
.
style
(
this
,
"backgroundPositionX"
),
"0%"
,
"Non-numeric start zeroed"
);
}
},
done
:
function
()
{
equal
(
jQuery
.
style
(
this
,
"backgroundPositionX"
),
"42%"
,
"End reached"
);
start
();
}
});
});
asyncTest
(
"Animation callbacks (#11797)"
,
15
,
function
()
{
var
targets
=
jQuery
(
"#foo"
).
children
(),
var
targets
=
jQuery
(
"#foo"
).
children
(),
done
=
false
,
done
=
false
,
expectedProgress
=
0
;
expectedProgress
=
0
;
targets
.
eq
(
0
).
animate
(
{},
{
targets
.
eq
(
0
).
animate
(
{},
{
duration
:
1
,
duration
:
1
,
start
:
function
()
{
ok
(
true
,
"empty: start"
);
},
progress
:
function
(
anim
,
percent
)
{
progress
:
function
(
anim
,
percent
)
{
equal
(
percent
,
0
,
"empty: progress 0"
);
equal
(
percent
,
0
,
"empty: progress 0"
);
},
},
...
@@ -1699,13 +1726,16 @@ asyncTest("Animation callbacks (#11797)", 12, function() {
...
@@ -1699,13 +1726,16 @@ asyncTest("Animation callbacks (#11797)", 12, function() {
}
}
});
});
ok
(
done
,
"
animation done
"
);
ok
(
done
,
"
empty: done immediately
"
);
done
=
false
;
done
=
false
;
targets
.
eq
(
1
).
animate
({
targets
.
eq
(
1
).
animate
({
opacity
:
0
opacity
:
0
},
{
},
{
duration
:
1
,
duration
:
1
,
start
:
function
()
{
ok
(
true
,
"stopped: start"
);
},
progress
:
function
(
anim
,
percent
)
{
progress
:
function
(
anim
,
percent
)
{
equal
(
percent
,
0
,
"stopped: progress 0"
);
equal
(
percent
,
0
,
"stopped: progress 0"
);
},
},
...
@@ -1721,12 +1751,15 @@ asyncTest("Animation callbacks (#11797)", 12, function() {
...
@@ -1721,12 +1751,15 @@ asyncTest("Animation callbacks (#11797)", 12, function() {
}
}
}).
stop
();
}).
stop
();
ok
(
done
,
"
animation stopped
"
);
ok
(
done
,
"
stopped: stopped immediately
"
);
targets
.
eq
(
2
).
animate
({
targets
.
eq
(
2
).
animate
({
opacity
:
0
opacity
:
0
},
{
},
{
duration
:
1
,
duration
:
1
,
start
:
function
()
{
ok
(
true
,
"async: start"
);
},
progress
:
function
(
anim
,
percent
)
{
progress
:
function
(
anim
,
percent
)
{
equal
(
percent
,
expectedProgress
,
"async: progress "
+
expectedProgress
);
equal
(
percent
,
expectedProgress
,
"async: progress "
+
expectedProgress
);
// once at 0, once at 1
// once at 0, once at 1
...
...
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