Commit 47368484 authored by Phil Hughes's avatar Phil Hughes

Doesnt run JS if active element doesnt exist

parent c04ef86c
...@@ -29,13 +29,16 @@ ...@@ -29,13 +29,16 @@
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 (offset > scrollingTabWidth - 30) { if ($active.length) {
var scrollLeft = scrollingTabWidth / 2; var offset = $active.offset().left + activeWidth;
scrollLeft = (offset - scrollLeft) - (activeWidth / 2);
$this.scrollLeft(scrollLeft); if (offset > scrollingTabWidth - 30) {
var scrollLeft = scrollingTabWidth / 2;
scrollLeft = (offset - scrollLeft) - (activeWidth / 2);
$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