I was going to try and write a directive for this jQuery WayPoints plugin http://imakewebthings.com/jquery-waypoints/#documentation
But then discovered AngularUI with jQuery Passthrough which claims to support 75% of jQuery plugins. http://angular-ui.github.com/
Can someone please write an example of how I could use this jQuery WayPoints plugin in my AngularJS app?
Here is a fiddle that appears to work using the AngularUI jQuery Passthrough with Waypoints. The main things to note are:
1) Include the angular-ui.js script (which is a pretty awesome AngularJS companion!)
2) Add ['ui']
in the requires parameter when registering the module
angular.module('waypoints', ['ui']);
3) Add a function in your controller that you want to call when the waypoint is hit
function WaypointsController($scope) {
$scope.test = function(){
alert('you have scrolled');
}
}
4) Set up the ui-jq
directive passing the function into the ui-options
<div ui-jq="waypoint" ui-options="test">
To answer Marco's question:
3) Add a function in your controller that you want to call when the waypoint is hit
function WaypointsController($scope) {
$scope.test = function(direction){
alert('you have scrolled ' + direction);
};
$scope.optionsObj = {
offset: 50
//additional options
};
}
4) Set up the ui-jq
directive passing the function into the ui-options
<div ui-jq="waypoint" ui-options="test, optionsObj">
Here is a fiddle showing this in action
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With