Commit 47368484 authored by Phil Hughes's avatar Phil Hughes

Doesnt run JS if active element doesnt exist

parent c04ef86c
...@@ -29,14 +29,17 @@ ...@@ -29,14 +29,17 @@
var $this = $(this), var $this = $(this),
scrollingTabWidth = $this.width(), scrollingTabWidth = $this.width(),
$active = $this.find('.active'), $active = $this.find('.active'),
activeWidth = $active.width(), activeWidth = $active.width();
offset = $active.offset().left + activeWidth;
if ($active.length) {
var offset = $active.offset().left + activeWidth;
if (offset > scrollingTabWidth - 30) { if (offset > scrollingTabWidth - 30) {
var scrollLeft = scrollingTabWidth / 2; var scrollLeft = scrollingTabWidth / 2;
scrollLeft = (offset - scrollLeft) - (activeWidth / 2); scrollLeft = (offset - scrollLeft) - (activeWidth / 2);
$this.scrollLeft(scrollLeft); $this.scrollLeft(scrollLeft);
} }
}
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment