From 275821bbb081890ffe232d50d4778eb15bdb1d7b Mon Sep 17 00:00:00 2001 From: Pierre Vanduynslager Date: Sat, 18 Mar 2017 21:24:54 -0400 Subject: HTMLElement.offset* by getBoundingClientRect() (#21788) * Replace element.offet* by getBoundingClientRect() * Use variable to store BoundingClientRect * Fix cc issue... --- js/src/scrollspy.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'js/src/scrollspy.js') diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 66b6080c8..15541b8ff 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -133,12 +133,15 @@ const ScrollSpy = (($) => { 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) { + const 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 }) @@ -198,7 +201,7 @@ const ScrollSpy = (($) => { _getOffsetHeight() { return this._scrollElement === window ? - window.innerHeight : this._scrollElement.offsetHeight + window.innerHeight : this._scrollElement.getBoundingClientRect().height } _process() { -- cgit v1.2.3 From 91b62941afb7115807fc2925398ebccfc68f5377 Mon Sep 17 00:00:00 2001 From: Pierre Vanduynslager Date: Sun, 2 Apr 2017 05:21:04 -0400 Subject: Tabs/Scrollspy/.nav/.list-group/.active independent of markup (