docs: function iscroll($rootScope, $timeout, $interval, iScrollSignals,
                       iScrollService) {
          function asyncRefresh(instance, options) {
              $timeout(function _refreshAfterInitialRender() {
                  instance.refresh();
              }, options.directive.asyncRefreshDelay, options.directive.invokeApply);
          }
  
          function _createInstance(scope, element, attrs, options) {
              var instance = new IScroll(element[0], options.iScroll),
                  refreshEnabled = true,
                  refreshInterval = null;
  
              angular.forEach(iScrollEventHandlerMap,
                  function _addHandler(event, option) {
                      if (angular.isDefined(options.directive[option])) {
                          instance.on(event, options.directive[option]);
                      }
                  });
  
              element.removeClass(classes.off).addClass(classes.on);
  
              if (angular.isDefined(attrs.iscrollInstance)) {
                  scope.iscrollInstance = instance;
              }
  
              if (options.directive.asyncRefreshDelay !== false) {
                  asyncRefresh(instance, options);
              }
  
              function _destroyInstance() {
                  if (refreshInterval !== null) {
                      $interval.cancel(refreshInterval);
                  }
  
                  if (angular.isDefined(scope.iscrollInstance)) {
                      delete scope.iscrollInstance;
                  }
                  instance.destroy();
  
                  element.removeClass(classes.on).addClass(classes.off);
                  // Remove element's CSS transition values:
                  element.children('.iscroll-scroller').attr('style', null);
  
                  angular.forEach(deregistrators, _call);
                  //$log.debug('angular-iscroll: destroyInstance');
              }
  
              function _refreshInstance() {
                  if (refreshEnabled) {
                      //noinspection JSUnusedAssignment
                      refreshEnabled = false;
                      asyncRefresh(instance, options);
                      refreshEnabled = true;
                  }
              }
  
              function _disableRefresh() {
                  refreshEnabled = false;
              }
  
              function _enableRefresh() {
                  refreshEnabled = true;
              }
  
              instance.on('scrollStart', _disableRefresh);
              instance.on('scrollEnd', _enableRefresh);
  
              if (options.directive.refreshInterval !== false) {
                  refreshInterval = $interval(_refreshInstance,
                      options.directive.refreshInterval, 0, options.directive.invokeApply);
              }
  
              var deregistrators = [
                  $rootScope.$on(iScrollSignals.disabled, _destroyInstance),
                  $rootScope.$on(iScrollSignals.refresh, _refreshInstance),
                  scope.$on('$destroy', _destroyInstance)
              ];
  
              return instance;
          }
  
          function _link(scope, element, attrs) {
              var options = {
                  iScroll: angular.extend({}, iScrollService.defaults.iScroll, scope.iscroll || {}),
                  directive: angular.extend({}, iScrollService.defaults.directive)
              };
  
              angular.forEach(options.iScroll,
                  function _extractOptions(value, key) {
                      if (iScrollService.defaults.directive.hasOwnProperty(key) ||
                          iScrollEventHandlerMap.hasOwnProperty(key)) {
                          options.directive[key] = value;
                          delete options.iScroll[key];
                      }
                  }
              );
  
              function _init() {
                  if (!element.hasClass(classes.on)) {
                      _createInstance(scope, element, attrs, options);
                  }
              }
  
              var enableHandlers = [$rootScope.$on(iScrollSignals.enabled, _init)];
  
              function _removeEnableHandlers() {
                  angular.forEach(enableHandlers, _call);
              }
  
              if (iScrollService.state.useIScroll) {
                  _init();
              } else {
                  element.removeClass(classes.on).addClass(classes.off);
              }
  
              scope.$on('$destroy', _removeEnableHandlers);
          }
  
          return {
              restrict: 'A',
              link: _link,
              scope: {
                  iscroll: '=',
                  iscrollInstance: '='
              }
          };
      }