Smooth scroll angular2

前端 未结 9 2224
旧巷少年郎
旧巷少年郎 2020-12-24 07:47

I am having trouble getting a smooth scroll service to work in angular 2. Are there any services for smooth scrolling, or plain anchor scrolling, that might work until the

9条回答
  •  心在旅途
    2020-12-24 08:14

    For anyone still on the search for a smooth scroll @alex-j 's answer works great for me in Angular 2.0 - but I had to change the Window service to this :-

    import { Injectable } from '@angular/core';
    
    function _window() : any {
        // return the global native browser window object
        return window;
    }
    
    @Injectable()
    export class WindowRef {
        get nativeWindow() : any {
            return _window();
        }
    }
    

    All props to this blog http://juristr.com/blog/2016/09/ng2-get-window-ref/ - now I have a smooth scroll service I can call from anywhere :)

提交回复
热议问题