Skip to content

Commit 40f6427

Browse files
Reinitialize pane
1 parent d616b98 commit 40f6427

6 files changed

+33
-11
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ angular.module("app").controller("MyCtrl", function () {
3737

3838
**Don't forget to specify an id for your scroll pane, otherwise it won't be working**
3939

40+
### Reinitialize the pane
41+
42+
If you want to reinitialize the pane, you can broadcast `reinit-pane` with the ID of the DOM Element.
43+
4044
## Contributing
4145

4246
If you wish to contribute, fork this repository.

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-scroll-pane",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"homepage": "https://github.com/lght/angular-scroll-pane",
55
"authors": [
66
"Geoffrey Bauduin <[email protected]>"

dist/angular-jscrollpane.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,23 @@
1414
config = $scope.$eval($attrs.scrollConfig);
1515
}
1616
fn = function() {
17-
return jQuery("#" + $attrs.id).jScrollPane(config);
17+
jQuery("#" + $attrs.id).jScrollPane(config);
18+
return $scope.pane = jQuery("#" + $attrs.id).data("jsp");
1819
};
1920
if ($attrs.scrollTimeout) {
20-
return $timeout(fn, $scope.$eval($attrs.scrollTimeout));
21+
$timeout(fn, $scope.$eval($attrs.scrollTimeout));
2122
} else {
22-
return fn();
23+
fn();
2324
}
25+
return $scope.$on("reinit-pane", function(event, id) {
26+
if (id === $attrs.id && $scope.pane) {
27+
console.log("Reinit pane " + id);
28+
return $scope.$apply(function() {
29+
$scope.pane.destroy();
30+
return fn();
31+
});
32+
}
33+
});
2434
},
2535
replace: true
2636
};

dist/angular-jscrollpane.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-scroll-pane",
3-
"version": "1.0.0",
3+
"version": "1.0.2",
44
"description": "AngularJS bindings for jScrollPane",
55
"main": "jscrollpane.js",
66
"scripts": {

src/jscrollpane.coffee

+12-4
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,20 @@ angular
99
link: ($scope, $elem, $attrs) ->
1010
config = {}
1111
if $attrs.scrollConfig
12-
config = $scope.$eval $attrs.scrollConfig
13-
fn = () ->
14-
jQuery("##{$attrs.id}").jScrollPane config
12+
config = $scope.$eval($attrs.scrollConfig)
13+
fn = ->
14+
jQuery("##{$attrs.id}").jScrollPane(config)
15+
$scope.pane = jQuery("##{$attrs.id}").data("jsp")
1516
if $attrs.scrollTimeout
16-
$timeout fn, $scope.$eval $attrs.scrollTimeout
17+
$timeout(fn, $scope.$eval($attrs.scrollTimeout))
1718
else
1819
do fn
20+
$scope.$on("reinit-pane", (event, id) ->
21+
if id is $attrs.id and $scope.pane
22+
console.log("Reinit pane #{id}")
23+
$scope.$apply ->
24+
$scope.pane.destroy()
25+
fn()
26+
)
1927
replace: true
2028
]

0 commit comments

Comments
 (0)