如何使用jQuery动画滚动到md-content中的md-card?

时间:2017-05-15 23:28:10

标签: javascript jquery html angular-material

我有以下HTML代码:

<body ng-app="MyApp">
    <div ng-controller="ctrl" layout="column" layout-fill ng-cloak>
    <md-sidenav class="md-sidenav-left" md-component-id="sidenav" md-disable-backdrop md-whiteframe="4">
        <md-toolbar class="md-theme-indigo">...</md-toolbar>
        <md-list></md-list>
    <md-sidenav>
    <div layout="column" flex>
        <md-content id="content">
            <div layout="column" flex>
                <md-card id="one" flex>…</md-card>
                <md-card id="two" flex>…</md-card>
                <!-- … -->
            </div>
        </md-content>
    </div>
</body>

我试图使用这个JS代码,但它不起作用:

$scope.scrollTo = function(item) {
    $mdSidenav('sidenav').toggle();
    $('#home-content').animate({
        scrollTop: $(item).offset().top
        }, 'slow');
}

item参数是mc-card的ID。我写了上面这段代码question。从scrollTo内的按钮调用md-list-item

0 个答案:

没有答案