Skip to content

Commit

Permalink
Remove the need to use $scope.$apply in event functions
Browse files Browse the repository at this point in the history
  • Loading branch information
getninjaN authored Jul 13, 2016
1 parent 6c82de4 commit 730b179
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions angular-sticky-kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,40 @@ angular.module("angular-sticky-kit", [])
}
stickyElement = element.stick_in_parent(options);
if (typeof options.stick !== "undefined" && options.stick !== null) {
element.on("sticky_kit:stick", options.stick);
element.on("sticky_kit:stick", function(event) {
var localScope = $(event.target).scope()
localScope.$apply(options.stick)
});
}
if (typeof options.unstick !== "undefined" && options.unstick !== null) {
element.on("sticky_kit:unstick", options.unstick);
element.on("sticky_kit:unstick", function(event) {
var localScope = $(event.target).scope()
localScope.$apply(options.unstick)
});
}
if (typeof options.bottom !== "undefined" && options.bottom !== null) {
element.on("sticky_kit:bottom", options.bottom);
element.on("sticky_kit:bottom", function(event) {
var localScope = $(event.target).scope()
localScope.$apply(options.bottom)
});
}
if (typeof options.unbottom !== "undefined" && options.unbottom !== null) {
element.on("sticky_kit:unbottom", options.unbottom);
element.on("sticky_kit:unbottom", function(event) {
var localScope = $(event.target).scope()
localScope.$apply(options.unbottom)
});
}
if (typeof options.recalc !== "undefined" && options.recalc !== null) {
element.on("sticky_kit:recalc", options.recalc);
element.on("sticky_kit:recalc", function(event) {
var localScope = $(event.target).scope()
localScope.$apply(options.recalc)
});
}
if (typeof options.detach !== "undefined" && options.detach !== null) {
return element.on("sticky_kit:detach", options.detach);
element.on("sticky_kit:detach", function(event) {
var localScope = $(event.target).scope()
localScope.$apply(options.detach)
});
}
}
};
Expand Down

0 comments on commit 730b179

Please sign in to comment.