Skip to content

Commit

Permalink
- Leave when scope is destroyed
Browse files Browse the repository at this point in the history
- Fix bower version
  • Loading branch information
hanni05 committed Jan 12, 2015
1 parent a9219a9 commit edfd563
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-tether",
"version": "0.2.0",
"version": "0.2.2",
"main": "./dist/angular-tether.js",
"repository": {
"type": "git",
Expand Down
6 changes: 5 additions & 1 deletion dist/angular-tether.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@
scope.$watch(function () {
tether.tetherInstance.position();
});
scope.$on('$destroy', function () {
scope.$applyAsync(tether.leave);
});
// prevents document instant click fire. there's no need to run digest cycle.
setTimeout(function () {
if (config.leaveOnBlur) {
Expand All @@ -140,6 +143,7 @@
function leaveOnBlur(evt) {
var target = evt.target;
if (tether.active === false || target === element[0]) {
target = null;
return;
}
while (target.parentElement !== null) {
Expand Down Expand Up @@ -176,7 +180,7 @@
return $animate.leave(element);
};
// backward compatible method until next major version is released
tether.isActive = function () {
tether.isActive = function isActive() {
return tether.active;
};
tether.active = false;
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-tether.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/angular-tether.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@
tether.tetherInstance.position();
});

scope.$on('$destroy', function(){
scope.$applyAsync(tether.leave);
});

// prevents document instant click fire. there's no need to run digest cycle.
setTimeout(function(){
if (config.leaveOnBlur) {
Expand All @@ -113,6 +117,7 @@
function leaveOnBlur(evt) {
var target = evt.target;
if (tether.active === false || target === element[0]) {
target = null;
return;
}

Expand Down Expand Up @@ -159,7 +164,7 @@
};

// backward compatible method until next major version is released
tether.isActive = function() {
tether.isActive = function isActive() {
return tether.active;
};

Expand Down

0 comments on commit edfd563

Please sign in to comment.