Explorar el Código

modify scroll

yohei0125 hace 4 años
padre
commit
7182b24f21
Se han modificado 1 ficheros con 2 adiciones y 10 borrados
  1. 2 10
      packages/app/src/client/util/smooth-scroll.ts

+ 2 - 10
packages/app/src/client/util/smooth-scroll.ts

@@ -16,20 +16,12 @@ export const smoothScrollIntoView = (element: HTMLElement, offsetTop = 0, scroll
 
 
 /**
 /**
  * scroll to the top of the target element
  * scroll to the top of the target element
- * or
- * scroll the target element to the center of the view
  * by using JQuery slimScroll: http://rocha.la/jQuery-slimScroll
  * by using JQuery slimScroll: http://rocha.la/jQuery-slimScroll
  */
  */
-export const jQuerySlimScrollIntoView = (scrollableElement: HTMLElement, scrollTargetElement: HTMLElement, shouldScrollTargetToCenter = false): void => {
-  const windowCenter = window.innerHeight / 2;
+export const jQuerySlimScrollIntoView = (scrollableElement: HTMLElement, scrollTargetElement: HTMLElement, offsetTop = 0): void => {
   const targetTop = scrollTargetElement.getBoundingClientRect().top;
   const targetTop = scrollTargetElement.getBoundingClientRect().top;
 
 
-  let scrollTo;
-  scrollTo = targetTop;
-  if (shouldScrollTargetToCenter) {
-    if (targetTop <= windowCenter) return;
-    scrollTo = targetTop - windowCenter;
-  }
+  const scrollTo = targetTop - offsetTop;
   (<any>$(scrollableElement)).slimScroll({ scrollTo });
   (<any>$(scrollableElement)).slimScroll({ scrollTo });
 };
 };