Skip to content

Commit 308cb8d

Browse files
committed
fix issue #16
1 parent 50ec9b5 commit 308cb8d

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

angular-slimscroll.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ angular.module('ui.slimscroll', []).directive('slimscroll', function () {
66
link: function ($scope, $elem, $attr) {
77
var off = [];
88
var option = {};
9+
10+
var refresh = function () {
11+
if ($attr.slimscroll) {
12+
option = $scope.$eval($attr.slimscroll);
13+
} else if ($attr.slimscrollOption) {
14+
option = $scope.$eval($attr.slimscrollOption);
15+
}
16+
17+
$($elem).slimScroll({ destroy: true });
918

10-
var init = function () {
11-
if ($attr.slimscroll) {
12-
option = $scope.$eval($attr.slimscroll);
13-
} else if ($attr.slimscrollOption) {
14-
option = $scope.$eval($attr.slimscrollOption);
15-
}
16-
17-
$($elem).slimScroll({ destroy: true });
18-
19-
$($elem).slimScroll(option);
20-
19+
$($elem).slimScroll(option);
20+
};
21+
22+
var registerWatch = function () {
2123
if ($attr.slimscroll && !option.noWatch) {
2224
off.push($scope.$watchCollection($attr.slimscroll, refresh));
2325
}
@@ -41,7 +43,7 @@ angular.module('ui.slimscroll', []).directive('slimscroll', function () {
4143

4244
off.push($scope.$on('$destroy', destructor));
4345

44-
init();
46+
registerWatch();
4547
}
4648
};
4749
});

0 commit comments

Comments
 (0)