@@ -120,7 +120,7 @@ jQuery.fn.extend({
120
120
} ,
121
121
122
122
animate : function ( prop , speed , easing , callback ) {
123
- var optall = jQuery . speed ( speed , easing , callback ) ;
123
+ var optall = jQuery . speed ( speed , easing , callback ) ;
124
124
125
125
if ( jQuery . isEmptyObject ( prop ) ) {
126
126
return this . each ( optall . complete , [ false ] ) ;
@@ -140,8 +140,7 @@ jQuery.fn.extend({
140
140
var opt = jQuery . extend ( { } , optall ) ,
141
141
isElement = this . nodeType === 1 ,
142
142
hidden = isElement && jQuery ( this ) . is ( ":hidden" ) ,
143
- name , val , p ,
144
- display , e ,
143
+ name , val , p , e ,
145
144
parts , start , end , unit ;
146
145
147
146
// will store per property easing and be used to determine when an animation is complete
@@ -182,21 +181,14 @@ jQuery.fn.extend({
182
181
// animated
183
182
if ( jQuery . css ( this , "display" ) === "inline" &&
184
183
jQuery . css ( this , "float" ) === "none" ) {
185
- if ( ! jQuery . support . inlineBlockNeedsLayout ) {
184
+
185
+ // inline-level elements accept inline-block;
186
+ // block-level elements need to be inline with layout
187
+ if ( ! jQuery . support . inlineBlockNeedsLayout || defaultDisplay ( this . nodeName ) === "inline" ) {
186
188
this . style . display = "inline-block" ;
187
189
188
190
} else {
189
- display = defaultDisplay ( this . nodeName ) ;
190
-
191
- // inline-level elements accept inline-block;
192
- // block-level elements need to be inline with layout
193
- if ( display === "inline" ) {
194
- this . style . display = "inline-block" ;
195
-
196
- } else {
197
- this . style . display = "inline" ;
198
- this . style . zoom = 1 ;
199
- }
191
+ this . style . zoom = 1 ;
200
192
}
201
193
}
202
194
}
@@ -210,7 +202,7 @@ jQuery.fn.extend({
210
202
e = new jQuery . fx ( this , opt , p ) ;
211
203
val = prop [ p ] ;
212
204
213
- if ( rfxtypes . test ( val ) ) {
205
+ if ( rfxtypes . test ( val ) ) {
214
206
e [ val === "toggle" ? hidden ? "show" : "hide" : val ] ( ) ;
215
207
216
208
} else {
@@ -259,10 +251,10 @@ jQuery.fn.extend({
259
251
jQuery . _unmark ( true , this ) ;
260
252
}
261
253
while ( i -- ) {
262
- if ( timers [ i ] . elem === this ) {
263
- if ( gotoEnd ) {
254
+ if ( timers [ i ] . elem === this ) {
255
+ if ( gotoEnd ) {
264
256
// force the next step to be the last
265
- timers [ i ] ( true ) ;
257
+ timers [ i ] ( true ) ;
266
258
}
267
259
268
260
timers . splice ( i , 1 ) ;
@@ -294,7 +286,7 @@ function clearFxNow() {
294
286
function genFx ( type , num ) {
295
287
var obj = { } ;
296
288
297
- jQuery . each ( fxAttrs . concat . apply ( [ ] , fxAttrs . slice ( 0 , num ) ) , function ( ) {
289
+ jQuery . each ( fxAttrs . concat . apply ( [ ] , fxAttrs . slice ( 0 , num ) ) , function ( ) {
298
290
obj [ this ] = type ;
299
291
} ) ;
300
292
@@ -303,9 +295,9 @@ function genFx( type, num ) {
303
295
304
296
// Generate shortcuts for custom animations
305
297
jQuery . each ( {
306
- slideDown : genFx ( "show" , 1 ) ,
307
- slideUp : genFx ( "hide" , 1 ) ,
308
- slideToggle : genFx ( "toggle" , 1 ) ,
298
+ slideDown : genFx ( "show" , 1 ) ,
299
+ slideUp : genFx ( "hide" , 1 ) ,
300
+ slideToggle : genFx ( "toggle" , 1 ) ,
309
301
fadeIn : { opacity : "show" } ,
310
302
fadeOut : { opacity : "hide" } ,
311
303
fadeToggle : { opacity : "toggle" }
@@ -317,15 +309,15 @@ jQuery.each({
317
309
318
310
jQuery . extend ( {
319
311
speed : function ( speed , easing , fn ) {
320
- var opt = speed && typeof speed === "object" ? jQuery . extend ( { } , speed ) : {
312
+ var opt = speed && typeof speed === "object" ? jQuery . extend ( { } , speed ) : {
321
313
complete : fn || ! fn && easing ||
322
314
jQuery . isFunction ( speed ) && speed ,
323
315
duration : speed ,
324
- easing : fn && easing || easing && ! jQuery . isFunction ( easing ) && easing
316
+ easing : fn && easing || easing && ! jQuery . isFunction ( easing ) && easing
325
317
} ;
326
318
327
319
opt . duration = jQuery . fx . off ? 0 : typeof opt . duration === "number" ? opt . duration :
328
- opt . duration in jQuery . fx . speeds ? jQuery . fx . speeds [ opt . duration ] : jQuery . fx . speeds . _default ;
320
+ opt . duration in jQuery . fx . speeds ? jQuery . fx . speeds [ opt . duration ] : jQuery . fx . speeds . _default ;
329
321
330
322
// Queueing
331
323
opt . old = opt . complete ;
@@ -372,12 +364,12 @@ jQuery.fx.prototype = {
372
364
this . options . step . call ( this . elem , this . now , this ) ;
373
365
}
374
366
375
- ( jQuery . fx . step [ this . prop ] || jQuery . fx . step . _default ) ( this ) ;
367
+ ( jQuery . fx . step [ this . prop ] || jQuery . fx . step . _default ) ( this ) ;
376
368
} ,
377
369
378
370
// Get the current size
379
371
cur : function ( ) {
380
- if ( this . elem [ this . prop ] != null && ( ! this . elem . style || this . elem . style [ this . prop ] == null ) ) {
372
+ if ( this . elem [ this . prop ] != null && ( ! this . elem . style || this . elem . style [ this . prop ] == null ) ) {
381
373
return this . elem [ this . prop ] ;
382
374
}
383
375
@@ -396,14 +388,13 @@ jQuery.fx.prototype = {
396
388
raf ;
397
389
398
390
this . startTime = fxNow || createFxNow ( ) ;
399
- this . start = from ;
400
391
this . end = to ;
401
- this . unit = unit || this . unit || ( jQuery . cssNumber [ this . prop ] ? "" : "px" ) ;
402
- this . now = this . start ;
392
+ this . now = this . start = from ;
403
393
this . pos = this . state = 0 ;
394
+ this . unit = unit || this . unit || ( jQuery . cssNumber [ this . prop ] ? "" : "px" ) ;
404
395
405
396
function t ( gotoEnd ) {
406
- return self . step ( gotoEnd ) ;
397
+ return self . step ( gotoEnd ) ;
407
398
}
408
399
409
400
t . elem = this . elem ;
@@ -429,13 +420,13 @@ jQuery.fx.prototype = {
429
420
// Simple 'show' function
430
421
show : function ( ) {
431
422
// Remember where we started, so that we can go back to it later
432
- this . options . orig [ this . prop ] = jQuery . style ( this . elem , this . prop ) ;
423
+ this . options . orig [ this . prop ] = jQuery . style ( this . elem , this . prop ) ;
433
424
this . options . show = true ;
434
425
435
426
// Begin the animation
436
427
// Make sure that we start at a small width/height to avoid any
437
428
// flash of content
438
- this . custom ( this . prop === "width" || this . prop === "height" ? 1 : 0 , this . cur ( ) ) ;
429
+ this . custom ( this . prop === "width" || this . prop === "height" ? 1 : 0 , this . cur ( ) ) ;
439
430
440
431
// Start by showing the element
441
432
jQuery ( this . elem ) . show ( ) ;
@@ -444,11 +435,11 @@ jQuery.fx.prototype = {
444
435
// Simple 'hide' function
445
436
hide : function ( ) {
446
437
// Remember where we started, so that we can go back to it later
447
- this . options . orig [ this . prop ] = jQuery . style ( this . elem , this . prop ) ;
438
+ this . options . orig [ this . prop ] = jQuery . style ( this . elem , this . prop ) ;
448
439
this . options . hide = true ;
449
440
450
441
// Begin the animation
451
- this . custom ( this . cur ( ) , 0 ) ;
442
+ this . custom ( this . cur ( ) , 0 ) ;
452
443
} ,
453
444
454
445
// Each step of an animation
@@ -467,7 +458,7 @@ jQuery.fx.prototype = {
467
458
options . animatedProperties [ this . prop ] = true ;
468
459
469
460
for ( i in options . animatedProperties ) {
470
- if ( options . animatedProperties [ i ] !== true ) {
461
+ if ( options . animatedProperties [ i ] !== true ) {
471
462
done = false ;
472
463
}
473
464
}
@@ -476,14 +467,14 @@ jQuery.fx.prototype = {
476
467
// Reset the overflow
477
468
if ( options . overflow != null && ! jQuery . support . shrinkWrapBlocks ) {
478
469
479
- jQuery . each ( [ "" , "X" , "Y" ] , function ( index , value ) {
480
- elem . style [ "overflow" + value ] = options . overflow [ index ] ;
470
+ jQuery . each ( [ "" , "X" , "Y" ] , function ( index , value ) {
471
+ elem . style [ "overflow" + value ] = options . overflow [ index ] ;
481
472
} ) ;
482
473
}
483
474
484
475
// Hide the element if the "hide" operation was done
485
476
if ( options . hide ) {
486
- jQuery ( elem ) . hide ( ) ;
477
+ jQuery ( elem ) . hide ( ) ;
487
478
}
488
479
489
480
// Reset the properties, if the item has been hidden or shown
@@ -508,8 +499,8 @@ jQuery.fx.prototype = {
508
499
this . state = n / options . duration ;
509
500
510
501
// Perform the easing function, defaults to swing
511
- this . pos = jQuery . easing [ options . animatedProperties [ this . prop ] ] ( this . state , n , 0 , 1 , options . duration ) ;
512
- this . now = this . start + ( ( this . end - this . start ) * this . pos ) ;
502
+ this . pos = jQuery . easing [ options . animatedProperties [ this . prop ] ] ( this . state , n , 0 , 1 , options . duration ) ;
503
+ this . now = this . start + ( ( this . end - this . start ) * this . pos ) ;
513
504
}
514
505
// Perform the next step of the animation
515
506
this . update ( ) ;
@@ -522,7 +513,7 @@ jQuery.fx.prototype = {
522
513
jQuery . extend ( jQuery . fx , {
523
514
tick : function ( ) {
524
515
for ( var timers = jQuery . timers , i = 0 ; i < timers . length ; ++ i ) {
525
- if ( ! timers [ i ] ( ) ) {
516
+ if ( ! timers [ i ] ( ) ) {
526
517
timers . splice ( i -- , 1 ) ;
527
518
}
528
519
}
@@ -553,14 +544,22 @@ jQuery.extend( jQuery.fx, {
553
544
554
545
_default : function ( fx ) {
555
546
if ( fx . elem . style && fx . elem . style [ fx . prop ] != null ) {
556
- fx . elem . style [ fx . prop ] = ( fx . prop === "width" || fx . prop === "height" ? Math . max ( 0 , fx . now ) : fx . now ) + fx . unit ;
547
+ fx . elem . style [ fx . prop ] = fx . now + fx . unit ;
557
548
} else {
558
549
fx . elem [ fx . prop ] = fx . now ;
559
550
}
560
551
}
561
552
}
562
553
} ) ;
563
554
555
+ // Adds width/height step functions
556
+ // Do not set anything below 0
557
+ jQuery . each ( [ "width" , "height" ] , function ( i , prop ) {
558
+ jQuery . fx . step [ prop ] = function ( fx ) {
559
+ jQuery . style ( fx . elem , prop , Math . max ( 0 , fx . now ) ) ;
560
+ } ;
561
+ } ) ;
562
+
564
563
if ( jQuery . expr && jQuery . expr . filters ) {
565
564
jQuery . expr . filters . animated = function ( elem ) {
566
565
return jQuery . grep ( jQuery . timers , function ( fn ) {
0 commit comments