many web site has feature for long page like when user scroll down bit then 
a arrow sign comes at right side and when user click on that arrow then 
pages scroll to top. i try to do the same with custom directive. my code is 
working but there is one issue that when programmatically page is scrolling 
upward then some time arrow sign is getting visible and invisible which 
looks bad. so my request please some one see my code in jsfiddle and 
suggest me what is wrong there which causes arrow sign getting visible and 
invisible.

here is my jsfiddle https://jsfiddle.net/tridip/hzgjcojg/2/

i have mixed bit jquery because i did not know how to achieve purely it by 
java script and jquery is very easy for having smooth effect with *animate 
function.*

please see my code and give your suggestion why some time arrow sign is 
getting visible and invisible during page scroll upward. 


*see my code* 

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope) {
  $scope.items = [];
  for (var i=0; i<100; i++) { $scope.items.push(i); }});

app.directive('scrollOnClick', function() {
  return {
    restrict: 'EA',
    template:'<a title="Click here to go top" class="scrollup" href="#" 
>Scroll</a>',
    link: function(scope, $elm) {
$(window).scroll(function () {
            if ($(this).scrollTop() > 300) {
                $('.scrollup').fadeIn();
            } else {
                $('.scrollup').fadeOut();
            }
    });   
      $elm.on('click', function() {
        //alert('hello');
        $("html,body").animate({scrollTop: 0}, "slow");
      });
    }
  }});

thanks

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to