-
Notifications
You must be signed in to change notification settings - Fork 26
/
angular-nicescroll.js
60 lines (42 loc) · 1.39 KB
/
angular-nicescroll.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
(function () {
'use strict';
//change
//test
angular
.module('angular-nicescroll', [])
.directive('ngNicescroll', ngNicescroll);
ngNicescroll.$inject = ['$rootScope','$parse'];
/* @ngInject */
function ngNicescroll($rootScope,$parse) {
// Usage:
//
// Creates:
//
var directive = {
link: link
};
return directive;
//Gandu
function link(scope, element, attrs, controller) {
var niceOption = scope.$eval(attrs.niceOption)
var niceScroll = $(element).niceScroll(niceOption);
var nice = $(element).getNiceScroll();
if (attrs.niceScrollObject) $parse(attrs.niceScrollObject).assign(scope, nice);
// on scroll end
niceScroll.onscrollend = function (data) {
if (this.newscrolly >= this.page.maxh) {
if (attrs.niceScrollEnd) scope.$evalAsync(attrs.niceScrollEnd);
}
if (data.end.y <= 0) {
// at top
if (attrs.niceScrollTopEnd) scope.$evalAsync(attrs.niceScrollTopEnd);
}
};
scope.$on('$destroy', function () {
if (angular.isDefined(niceScroll.version)) {
niceScroll.remove();
}
})
}
}
})();