From ae50bb784506b4aa6b79598c2000c1d20843b5fd Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Sat, 18 Mar 2017 18:47:57 -0700 Subject: grunt --- js/dist/scrollspy.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'js/dist/scrollspy.js') diff --git a/js/dist/scrollspy.js b/js/dist/scrollspy.js index 52cf3de3b..10fc3c394 100644 --- a/js/dist/scrollspy.js +++ b/js/dist/scrollspy.js @@ -126,9 +126,12 @@ var ScrollSpy = function ($) { target = $(targetSelector)[0]; } - if (target && (target.offsetWidth || target.offsetHeight)) { - // todo (fat): remove sketch reliance on jQuery position/offset - return [$(target)[offsetMethod]().top + offsetBase, targetSelector]; + if (target) { + var targetBCR = target.getBoundingClientRect(); + if (targetBCR.width || targetBCR.height) { + // todo (fat): remove sketch reliance on jQuery position/offset + return [$(target)[offsetMethod]().top + offsetBase, targetSelector]; + } } return null; }).filter(function (item) { @@ -183,7 +186,7 @@ var ScrollSpy = function ($) { }; ScrollSpy.prototype._getOffsetHeight = function _getOffsetHeight() { - return this._scrollElement === window ? window.innerHeight : this._scrollElement.offsetHeight; + return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height; }; ScrollSpy.prototype._process = function _process() { -- cgit v1.2.3 From 364e01885fadeb341e1000d6f50291e5a5ada199 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Sat, 8 Apr 2017 13:22:53 -0700 Subject: grunt --- js/dist/scrollspy.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'js/dist/scrollspy.js') diff --git a/js/dist/scrollspy.js b/js/dist/scrollspy.js index 10fc3c394..e8be562ec 100644 --- a/js/dist/scrollspy.js +++ b/js/dist/scrollspy.js @@ -47,18 +47,15 @@ var ScrollSpy = function ($) { var ClassName = { DROPDOWN_ITEM: 'dropdown-item', DROPDOWN_MENU: 'dropdown-menu', - NAV_LINK: 'nav-link', - NAV: 'nav', ACTIVE: 'active' }; var Selector = { DATA_SPY: '[data-spy="scroll"]', ACTIVE: '.active', - LIST_ITEM: '.list-item', - LI: 'li', - LI_DROPDOWN: 'li.dropdown', + NAV_LIST_GROUP: '.nav, .list-group', NAV_LINKS: '.nav-link', + LIST_ITEMS: '.list-group-item', DROPDOWN: '.dropdown', DROPDOWN_ITEMS: '.dropdown-item', DROPDOWN_TOGGLE: '.dropdown-toggle' @@ -84,7 +81,7 @@ var ScrollSpy = function ($) { this._element = element; this._scrollElement = element.tagName === 'BODY' ? window : element; this._config = this._getConfig(config); - this._selector = this._config.target + ' ' + Selector.NAV_LINKS + ',' + (this._config.target + ' ' + Selector.DROPDOWN_ITEMS); + this._selector = this._config.target + ' ' + Selector.NAV_LINKS + ',' + (this._config.target + ' ' + Selector.LIST_ITEMS + ',') + (this._config.target + ' ' + Selector.DROPDOWN_ITEMS); this._offsets = []; this._targets = []; this._activeTarget = null; @@ -238,9 +235,11 @@ var ScrollSpy = function ($) { $link.closest(Selector.DROPDOWN).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE); $link.addClass(ClassName.ACTIVE); } else { - // todo (fat) this is kinda sus... - // recursively add actives to tested nav-links - $link.parents(Selector.LI).find('> ' + Selector.NAV_LINKS).addClass(ClassName.ACTIVE); + // Set triggered link as active + $link.addClass(ClassName.ACTIVE); + // Set triggered links parents as active + // With both