]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Scrollspy: enable smooth-scroll behavior (#36528)
authorGeoSot <geo.sotis@gmail.com>
Wed, 8 Jun 2022 19:35:09 +0000 (22:35 +0300)
committerGitHub <noreply@github.com>
Wed, 8 Jun 2022 19:35:09 +0000 (22:35 +0300)
js/src/scrollspy.js
js/tests/unit/scrollspy.spec.js

index 323194c53420cab0f6645eed71a71fdf4f151db5..33447c2bd5ed84f7b3bb6f24466e84d74ee1af20 100644 (file)
@@ -128,7 +128,7 @@ class ScrollSpy extends BaseComponent {
         const root = this._rootElement || window
         const height = observableSection.offsetTop - this._element.offsetTop
         if (root.scrollTo) {
-          root.scrollTo({ top: height })
+          root.scrollTo({ top: height, behavior: 'smooth' })
           return
         }
 
index 2cfc480392b35106781eb9466e8cc9589103d0b0..2bdeb5830cfff231ff84f68743bd1553e35ca894 100644 (file)
@@ -889,7 +889,7 @@ describe('ScrollSpy', () => {
 
       setTimeout(() => {
         if (div.scrollTo) {
-          expect(clickSpy).toHaveBeenCalledWith({ top: observable.offsetTop - div.offsetTop })
+          expect(clickSpy).toHaveBeenCalledWith({ top: observable.offsetTop - div.offsetTop, behavior: 'smooth' })
         } else {
           expect(clickSpy).toHaveBeenCalledWith(observable.offsetTop - div.offsetTop)
         }