离子降低滚动速度 [英] Ionic Decrease Scroll Speed

查看:75
本文介绍了离子降低滚动速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试减慢此代码的滚动时出现问题:

  $ ionicScrollDelegate。$ getByHandle('credit')。 scrollBottom(真)。 

如何减慢滚动速度?因为现在滚动速度太快了。我需要放慢滚动速度,就像星球大战电影中的信用场景一样。



Anyhelp非常感谢,谢谢!

  $ scope.viewCreditsV2 = 
function(){
$ ionicModal.fromTemplateUrl('views / popupcredit.html',{
范围:$ scope,
animation:'slide-in-up'
})。then(function(modal){
$ scope.modal = modal;
$ scope。 modal.show();
if($ scope.modal.isShown()){
setTimeout(function(){
// 2秒后做一些事情
$ ionicScrollDelegate。 $ getByHandle('credit')。scrollBottom(true);
},2000);
}
});

$ scope.openModal = function(){
$ scope.modal.show();
};
$ scope.closeModal = function(){
// $ scope.modal.hide();
$ scope.modal.remove();
};
};


解决方案

这个问题很老但有人可能会使用它。



即使没有参数传递选项,您仍然可以使用 $ ionScrollDelegate 来访问ScrollView对象。 / p>

按照@Jeremy Wilken的回答(帮助我推导出这个),你可以这样做:

  $ timeout(function(){
$ ionicScrollDelegate.getScrollView()。options.animationDuration = 400;
console.log($ ionicScrollDelegate.getScrollView()。options);
});


// .....

$ ionicScrollDelegate.scrollBy(0,20,true)//现在动画会变慢

我将电话打包在 $ timeout 上以避免赛车条件 $ ionicScrollDelegate 未创建。


i got problem when trying to slowing scroll from this code :

$ionicScrollDelegate.$getByHandle('credit').scrollBottom(true). 

How can i slowing down the scroll? Because now it scrolling too fast for me. I need to slowing down the scroll, just like credit scene on the Star Wars movie.

Anyhelp would be much appreciated, thanks!

$scope.viewCreditsV2 = 
            function () {
                $ionicModal.fromTemplateUrl('views/popupcredit.html', {
                    scope: $scope,
                    animation: 'slide-in-up'
                }).then(function(modal) {
                        $scope.modal = modal;
                        $scope.modal.show();
                        if ($scope.modal.isShown()){                               
                            setTimeout(function() {
                                  // Do something after 2 seconds
                                 $ionicScrollDelegate.$getByHandle('credit').scrollBottom(true);
                            }, 2000);
                        }
                    });

                $scope.openModal = function() {
                    $scope.modal.show();
                };
                $scope.closeModal = function() {
                    // $scope.modal.hide();
                    $scope.modal.remove();
                };
            };

解决方案

This question is old but somebody might use it.

Even though there are no parameters to pass options, you can still access the ScrollView object using the $ionScrollDelegate.

Following @Jeremy Wilken's answer (which helped me derive this one), you could do:

$timeout(function() {
    $ionicScrollDelegate.getScrollView().options.animationDuration = 400;
    console.log($ionicScrollDelegate.getScrollView().options);
});


//.....

$ionicScrollDelegate.scrollBy(0,20, true) // Animation will be slower now

I wrapped the call on a $timeout to avoid racing conditions from $ionicScrollDelegate not being created.

这篇关于离子降低滚动速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆