Kaynağa Gözat

Merge pull request #745 from rudiedirkx/scrollIntoView

#744 Use scrollIntoView instead of calculating scrollTop
Jordi Boggiano 8 yıl önce
ebeveyn
işleme
86787bfa0a

+ 1 - 10
src/Packagist/WebBundle/Resources/public/js/search.js

@@ -143,16 +143,7 @@
             currentSelected.removeClass('selected');
             nextSelected.addClass('selected');
 
-            var elTop = nextSelected.position().top,
-                elHeight = nextSelected.height(),
-                windowTop = $(window).scrollTop(),
-                windowHeight = $(window).height();
-
-            if (elTop < windowTop) {
-                $(window).scrollTop(elTop);
-            } else if (elTop + elHeight > windowTop + windowHeight) {
-                $(window).scrollTop(elTop + elHeight + 20 - windowHeight);
-            }
+            nextSelected.get(0).scrollIntoView(false);
         }
     });