Skip to content

Commit be5f2aa

Browse files
committed
if parentSelector is provided, but there is no such parent for this element - use immediate parent. Otherwise there will be 0 height.
1 parent 92abf74 commit be5f2aa

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

jquery.flexverticalcenter.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
// recalculate the distance to the top of the element to keep it centered
2626
var resizer = function () {
2727

28-
var parentHeight = (settings.parentSelector) ? $this.parents(settings.parentSelector).first().height() : $this.parent().height();
28+
var parentHeight = (settings.parentSelector && $this.parents(settings.parentSelector).length) ?
29+
$this.parents(settings.parentSelector).first().height() : $this.parent().height();
2930

3031
$this.css(
3132
settings.cssAttribute, ( ( ( parentHeight - $this.height() ) / 2 ) + parseInt(settings.verticalOffset) )

0 commit comments

Comments
 (0)