Skip to content
This repository was archived by the owner on Feb 3, 2018. It is now read-only.
This repository was archived by the owner on Feb 3, 2018. It is now read-only.

hold functions are not working properly on mixed events #13

@feyyazakkus

Description

@feyyazakkus

I have a directive which creates buttons for scroll up and down events. I used this directive plugin in my own directive's templates. When i mixed hold and secure-tap events sometimes hold functions are not working. I really dont know why. But secure-tab functions always working.

And if i use only tab events its also working as its supposed to be.

I am testing this in chrome with some mobile window extention.

Here is my directive:

  app.directive('scrollUpDown', function () {

      var scrolled = 0, docHeight;

      return {
        restrict: 'EA',
        template: '<div class="scroll-up-down-buttons" ng-show="display">' +
            '<p><span mn-touch secure-tap="tapUp()" threshold="30" hold="holdUp()" holdfor="600" class="glyphicon glyphicon-circle-arrow-up"></span></p>' +
            '<p><span mn-touch secure-tap="tapDown()" threshold="30" hold="holdDown()" holdfor="600" class="glyphicon glyphicon-circle-arrow-down"></span></p>' +
        '</div>',

        link: function (scope, element, attrs) {

          // if mobile device
          scope.display = ($(window).width() <= 768) ? true : false;

          if (scope.display) {
            $(window).scroll(function () {
              scrolled = $(this).scrollTop();
            });
          }
          docHeight = $(document).height();
        },

        controller: function ($scope) {

          $scope.tapUp = function () {
            console.log("tapUp");
            scrolled = scrolled - 150;
            $('body').animate({ scrollTop: scrolled });
          };

          $scope.tapDown = function () {
            console.log("tapDown");
            scrolled = scrolled + 150;
            $('body').animate({ scrollTop: scrolled });
          };

          $scope.holdUp = function () {
            console.log("holdUp");
            //console.log($event.name + ': %o', $event);
            $('body').animate({ scrollTop: 0 });
          };

          $scope.holdDown = function () {
            console.log("holdDown");
            $('body').animate({ scrollTop: docHeight });
          };
        }
      }
  }); // directive end

Hope you can help thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions