diff --git a/README.md b/README.md
index 0afa740..1a20c2f 100644
--- a/README.md
+++ b/README.md
@@ -37,9 +37,11 @@ angular.module('myApp', ['angularViewportWatch']);
## Directive Usage
```html
-
...
+...
```
+To specify a different container to look at and listen to you can specify `viewport-watch-container`. It accepts a querySelector string.
+
## Manual watcher toggling
In some cases you might want to disable or enable the watchers of some scope regardless of its position relative to the view port. This can be done easily by broadcasting an event to this scope (this will effect only scopes that have the `viewport-watch` directive on them):
diff --git a/angular-viewport-watch.js b/angular-viewport-watch.js
index a4b9cff..6985f09 100644
--- a/angular-viewport-watch.js
+++ b/angular-viewport-watch.js
@@ -1,7 +1,7 @@
"use strict";
(function() {
- function viewportWatch(scrollMonitor, $timeout) {
+ function viewportWatch(scrollMonitor, $timeout, $parse) {
var viewportUpdateTimeout;
function debouncedViewportUpdate() {
$timeout.cancel(viewportUpdateTimeout);
@@ -12,7 +12,14 @@
return {
restrict: "AE",
link: function(scope, element, attr) {
- var elementWatcher = scrollMonitor.create(element, scope.$eval(attr.viewportWatch || "0"));
+ if($parse(attr.viewportWatch)(scope) == false){
+ return false;
+ }
+
+ var container = (attr.viewportWatchContainer && attr.viewportWatchContainer.length > 1) ? attr.viewportWatchContainer : undefined;
+
+ var elementWatcher = scrollMonitor.create(element, scope.$eval(attr.viewportWatch || "0"), container);
+
function watchDuringDisable() {
this.$$watchersBackup = this.$$watchersBackup || [];
this.$$watchers = this.$$watchersBackup;
@@ -73,6 +80,6 @@
}
};
}
- viewportWatch.$inject = [ "scrollMonitor", "$timeout" ];
+ viewportWatch.$inject = [ "scrollMonitor", "$timeout", "$parse" ];
angular.module("angularViewportWatch", []).directive("viewportWatch", viewportWatch).value("scrollMonitor", window.scrollMonitor);
})();
\ No newline at end of file
diff --git a/bower.json b/bower.json
index 67a7b7a..71eb9e0 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "angular-viewport-watch",
- "version": "0.1.4",
+ "version": "0.1.10",
"main": "angular-viewport-watch.js",
"ignore": [
".*",
@@ -17,7 +17,7 @@
],
"dependencies": {
"angular": "^1.2.0",
- "scrollMonitor": "~1.0.10"
+ "scrollMonitor": "https://github.com/dirkgroenen/scrollMonitor.git#1.0.15"
},
"devDependencies": {
"angular-mocks": "^1.2.0",
diff --git a/package.json b/package.json
index 4f04596..9cf3651 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,7 @@
{
"name": "angular-viewport-watch",
- "version": "0.0.0",
+ "version": "0.1.11",
+ "main": "angular-viewport-watch.js",
"dependencies": {},
"devDependencies": {
"coveralls": "^2.10.0",