Skip to content

Commit

Permalink
12 more...
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 authored and gnarf committed Apr 20, 2012
1 parent ec70f22 commit 9973885
Showing 1 changed file with 30 additions and 35 deletions.
65 changes: 30 additions & 35 deletions src/effects.js
Expand Up @@ -44,14 +44,12 @@ var fxNow, timerId, iframe, iframeDoc,

// Animations created synchronously will run synchronously
function createFxNow() {
setTimeout( clearFxNow, 0 );
setTimeout(function() {
fxNow = undefined;
}, 0 );
return ( fxNow = jQuery.now() );
}

function clearFxNow() {
fxNow = undefined;
}

function callTweeners( animation, props ) {
jQuery.each( props, function( prop, value ) {
var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
Expand All @@ -71,25 +69,25 @@ function Animation( elem, properties, options ) {
index = 0,
tweenerIndex = 0,
length = preFilters.length,
finished = jQuery.Callbacks("once memory"),
finished = jQuery.Deferred(),
deferred = jQuery.Deferred().always(function( ended ) {
// remove cirular reference
delete animation.tick;

if ( deferred.isResolved() || ended ) {
if ( deferred.state() === "resolved" || ended ) {
// fire callbacks
finished.fireWith( this );
finished.resolveWith( this );
}
}),
animation = {
animation = deferred.promise({
elem: elem,
originalProperties: properties,
originalOptions: options,
props: jQuery.extend( {}, properties ),
opts: jQuery.extend( {}, options ),
startTime: fxNow || createFxNow(),
duration: options.duration,
finish: finished.add,
finish: finished.done,
tweens: [],
createTween: function( prop, end, easing ) {
var tween = jQuery.Tween( elem, animation.opts, prop, end,
Expand Down Expand Up @@ -117,31 +115,28 @@ function Animation( elem, properties, options ) {
},
stop: function( gotoEnd ) {
var index = 0,
length = animation.tweens.length;
length = gotoEnd ? animation.tweens.length : 0;

if ( gotoEnd ) {
for ( ; index < length ; index++ ) {
animation.tweens[ index ].run( 1 );
}
for ( ; index < length ; index++ ) {
animation.tweens[ index ].run( 1 );
}
deferred.rejectWith( elem, [ gotoEnd ] );
return this;
}
};

deferred.promise( animation );
}),
props = animation.props;

propFilter( animation.props );
propFilter( props );

for ( ; index < length ; index++ ) {
result = preFilters[ index ].call( animation,
elem, animation.props, animation.opts );
elem, props, animation.opts );
if ( result ) {
return result;
}
}

callTweeners( animation, animation.props );
callTweeners( animation, props );

jQuery.extend( animation.tick, {
anim: animation,
Expand Down Expand Up @@ -174,9 +169,10 @@ function propFilter( props ) {
// not quite $.extend, this wont overwrite keys already present.
// also - reusing 'index' from above because we have the correct "name"
for ( index in replace ) {
if ( ! ( index in props ) ) {
props[ index ] = replace[ index ];
if ( index in props ) {
continue;
}
props[ index ] = replace[ index ];
}
}
}
Expand Down Expand Up @@ -257,8 +253,8 @@ Animation.preFilter(function( elem, props, opts ) {
Animation.preFilter(function( elem, props, opts ) {
var index, prop, value, length, dataShow, tween,
orig = {},
hidden = jQuery( elem ).is(":hidden"),
handled = [];
handled = [],
hidden = jQuery( elem ).is(":hidden");

for ( index in props ) {
value = props[ index ];
Expand Down Expand Up @@ -297,12 +293,11 @@ Animation.preFilter(function( elem, props, opts ) {
tween = this.createTween( prop, hidden ? dataShow[ prop ] : 0 );
orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop );

if ( !(prop in dataShow) ) {
if ( !( prop in dataShow ) ) {
dataShow[ prop ] = tween.start;
if ( hidden ) {
tween.end = dataShow[ prop ] = tween.start;
tween.end = tween.start;
tween.start = prop === "width" || prop === "height" ? 1 : 0;
} else {
dataShow[ prop ] = tween.start;
}
}
}
Expand Down Expand Up @@ -506,6 +501,12 @@ jQuery.fn.extend({
}

return this.each(function() {
function stopQueue( elem, data, index ) {
var hooks = data[ index ];
jQuery.removeData( elem, index, true );
hooks.stop( gotoEnd );
}

var index,
hadTimers = false,
timers = jQuery.timers,
Expand All @@ -516,12 +517,6 @@ jQuery.fn.extend({
jQuery._unmark( true, this );
}

function stopQueue( elem, data, index ) {
var hooks = data[ index ];
jQuery.removeData( elem, index, true );
hooks.stop( gotoEnd );
}

if ( type == null ) {
for ( index in data ) {
if ( data[ index ] && data[ index ].stop && index.indexOf(".run") === index.length - 4 ) {
Expand Down

0 comments on commit 9973885

Please sign in to comment.