0

I would like to move to any element (id) on my page. I have this code that moves to the top.

$window.scrollTo(0, angular.element(document.getElementById('content')).offsetTop);

This code moves me to the top of the page, only, it goes there "fast". I need to make it move a bit "slower". Also, it only goes to the top. Can I make it go anywhere in my page? This is the complete code where I implement this.

$scope.uploadFiles = function(file, errFiles) {
    $scope.f = file;
    $scope.errFile = errFiles && errFiles[0];
    if (file) {
        file.upload = Upload.upload({
            url: '/Account/ReceiveUpload',
            data: { file: file }
        });
    }

    file.upload.then(function (response) {
        debugger;
        $rootScope.avatar = "data:image/png;base64," + response.data.avatar;
        $window.scrollTo(0, angular.element(document.getElementById('content')).offsetTop);
    })
};
stack questions
  • 862
  • 2
  • 15
  • 29
  • 1
    You can have a look at [this fiddle](http://jsfiddle.net/36dp03ur/) that plays with scroll speed. It is initiated by mouse scroll, but then you may reuse event handler. – RaphaMex Jan 19 '18 at 03:13
  • You can refer this (answer)[https://stackoverflow.com/a/10063405/3569893] – Ashish Jan 19 '18 at 04:24

0 Answers0