File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 14
14
var settings = $ . extend ( {
15
15
cssAttribute : 'margin-top' , // the attribute to apply the calculated value to
16
16
verticalOffset : 0 , // the number of pixels to offset the vertical alignment by
17
- parentSelector : null // a selector representing the parent to vertically center this element within
17
+ parentSelector : null , // a selector representing the parent to vertically center this element within
18
+ debounceTimeout : 25 // a default debounce timeout in milliseconds
18
19
} , options || { } ) ;
20
+ var debounce ;
19
21
20
22
return this . each ( function ( ) {
21
23
var $this = $ ( this ) ; // store the object
22
24
23
25
// recalculate the distance to the top of the element to keep it centered
24
26
var resizer = function ( ) {
27
+
25
28
var parentHeight = ( settings . parentSelector ) ? $this . parents ( settings . parentSelector ) . first ( ) . height ( ) : $this . parent ( ) . height ( ) ;
26
29
27
30
$this . css (
33
36
resizer ( ) ;
34
37
35
38
// Call on resize. Opera debounces their resize by default.
36
- $ ( window ) . resize ( resizer ) ;
39
+ $ ( window ) . resize ( function ( ) {
40
+ clearTimeout ( debounce ) ;
41
+ debounce = setTimeout ( resizer , settings . debounceTimeout ) ;
42
+ } ) ;
37
43
38
44
// Apply a load event to images within the element so it fires again after an image is loaded
39
45
$this . find ( 'img' ) . load ( resizer ) ;
You can’t perform that action at this time.
0 commit comments