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
b7f9e626
Commit
b7f9e626
authored
May 05, 2015
by
Timmy Willison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Effects: set default easing using jQuery.easing._default
Fixes gh-2219 Close gh-2218
parent
d6933917
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
18 deletions
+42
-18
effects.js
src/effects.js
+4
-1
Tween.js
src/effects/Tween.js
+3
-2
effects.js
test/unit/effects.js
+35
-15
No files found.
src/effects.js
View file @
b7f9e626
...
...
@@ -286,7 +286,10 @@ function Animation( elem, properties, options ) {
animation
=
deferred
.
promise
({
elem
:
elem
,
props
:
jQuery
.
extend
(
{},
properties
),
opts
:
jQuery
.
extend
(
true
,
{
specialEasing
:
{}
},
options
),
opts
:
jQuery
.
extend
(
true
,
{
specialEasing
:
{},
easing
:
jQuery
.
easing
.
_default
},
options
),
originalProperties
:
properties
,
originalOptions
:
options
,
startTime
:
fxNow
||
createFxNow
(),
...
...
src/effects/Tween.js
View file @
b7f9e626
...
...
@@ -13,7 +13,7 @@ Tween.prototype = {
init
:
function
(
elem
,
options
,
prop
,
end
,
easing
,
unit
)
{
this
.
elem
=
elem
;
this
.
prop
=
prop
;
this
.
easing
=
easing
||
"swing"
;
this
.
easing
=
easing
||
jQuery
.
easing
.
_default
;
this
.
options
=
options
;
this
.
start
=
this
.
now
=
this
.
cur
();
this
.
end
=
end
;
...
...
@@ -105,7 +105,8 @@ jQuery.easing = {
},
swing
:
function
(
p
)
{
return
0.5
-
Math
.
cos
(
p
*
Math
.
PI
)
/
2
;
}
},
_default
:
"swing"
};
jQuery
.
fx
=
Tween
.
prototype
.
init
;
...
...
test/unit/effects.js
View file @
b7f9e626
...
...
@@ -1191,45 +1191,45 @@ test("animate with per-property easing", function(){
test
(
"animate with CSS shorthand properties"
,
function
(){
expect
(
11
);
var
_default
_count
=
0
,
_special
_count
=
0
,
var
easeAnimation
_count
=
0
,
easeProperty
_count
=
0
,
propsBasic
=
{
"padding"
:
"10 20 30"
},
propsSpecial
=
{
"padding"
:
[
"1 2 3"
,
"
_special
"
]
};
propsSpecial
=
{
"padding"
:
[
"1 2 3"
,
"
propertyScope
"
]
};
jQuery
.
easing
.
_default
=
function
(
p
)
{
jQuery
.
easing
.
animationScope
=
function
(
p
)
{
if
(
p
>=
1
)
{
_default
_count
++
;
easeAnimation
_count
++
;
}
return
p
;
};
jQuery
.
easing
.
_special
=
function
(
p
)
{
jQuery
.
easing
.
propertyScope
=
function
(
p
)
{
if
(
p
>=
1
)
{
_special
_count
++
;
easeProperty
_count
++
;
}
return
p
;
};
jQuery
(
"#foo"
)
.
animate
(
propsBasic
,
200
,
"
_default
"
,
function
()
{
.
animate
(
propsBasic
,
200
,
"
animationScope
"
,
function
()
{
equal
(
this
.
style
.
paddingTop
,
"10px"
,
"padding-top was animated"
);
equal
(
this
.
style
.
paddingLeft
,
"20px"
,
"padding-left was animated"
);
equal
(
this
.
style
.
paddingRight
,
"20px"
,
"padding-right was animated"
);
equal
(
this
.
style
.
paddingBottom
,
"30px"
,
"padding-bottom was animated"
);
equal
(
_default
_count
,
4
,
"per-animation default easing called for each property"
);
_default
_count
=
0
;
equal
(
easeAnimation
_count
,
4
,
"per-animation default easing called for each property"
);
easeAnimation
_count
=
0
;
})
.
animate
(
propsSpecial
,
200
,
"
_default
"
,
function
()
{
.
animate
(
propsSpecial
,
200
,
"
animationScope
"
,
function
()
{
equal
(
this
.
style
.
paddingTop
,
"1px"
,
"padding-top was animated again"
);
equal
(
this
.
style
.
paddingLeft
,
"2px"
,
"padding-left was animated again"
);
equal
(
this
.
style
.
paddingRight
,
"2px"
,
"padding-right was animated again"
);
equal
(
this
.
style
.
paddingBottom
,
"3px"
,
"padding-bottom was animated again"
);
equal
(
_default
_count
,
0
,
"per-animation default easing not called"
);
equal
(
_special
_count
,
4
,
"special easing called for each property"
);
equal
(
easeAnimation
_count
,
0
,
"per-animation default easing not called"
);
equal
(
easeProperty
_count
,
4
,
"special easing called for each property"
);
jQuery
(
this
).
css
(
"padding"
,
"0"
);
delete
jQuery
.
easing
.
_default
;
delete
jQuery
.
easing
.
_special
;
delete
jQuery
.
easing
.
animationScope
;
delete
jQuery
.
easing
.
propertyScope
;
});
this
.
clock
.
tick
(
400
);
});
...
...
@@ -2227,5 +2227,25 @@ test( "Animation should go to its end state if document.hidden = true", 1, funct
}
});
test
(
"jQuery.easing._default (#2218)"
,
2
,
function
()
{
jQuery
(
"#foo"
)
.
animate
({
width
:
"5px"
},
{
duration
:
5
,
start
:
function
(
anim
)
{
equal
(
anim
.
opts
.
easing
,
jQuery
.
easing
.
_default
,
"anim.opts.easing should be equal to jQuery.easing._default when the easing argument is not given"
);
}
})
.
animate
({
height
:
"5px"
},
{
duration
:
5
,
easing
:
"linear"
,
start
:
function
(
anim
)
{
equal
(
anim
.
opts
.
easing
,
"linear"
,
"anim.opts.easing should be equal to the easing argument"
);
}
})
.
stop
();
this
.
clock
.
tick
(
25
);
});
})();
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