Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03c6870
commit 2c93783
Showing
12 changed files
with
603 additions
and
910 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "ngInfiniteScroll", | ||
"main": "build/ng-infinite-scroll.js", | ||
"ignore": [ | ||
"**/.*", | ||
"_*", | ||
"node_modules", | ||
"compile", | ||
"test", | ||
"Gruntfile.coffee", | ||
".*" | ||
], | ||
"dependencies": { | ||
"angular": ">=1.2.0" | ||
}, | ||
"homepage": "https://github.com/sroze/ngInfiniteScroll", | ||
"version": "1.2.2", | ||
"_release": "1.2.2", | ||
"_resolution": { | ||
"type": "version", | ||
"tag": "1.2.2", | ||
"commit": "f2fbba21726d5fd4889aeb087491d99f491e14e1" | ||
}, | ||
"_source": "https://github.com/sroze/ngInfiniteScroll.git", | ||
"_target": "^1.2.2", | ||
"_originalSource": "ngInfiniteScroll", | ||
"_direct": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2012 Brandon Tilley | ||
|
||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
files (the "Software"), to deal in the Software without | ||
restriction, including without limitation the rights to use, | ||
copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
![logo](http://sroze.github.com/ngInfiniteScroll/images/logo-resized.png) | ||
|
||
[![Build Status](https://travis-ci.org/sroze/ngInfiniteScroll.png?branch=master)](https://travis-ci.org/sroze/ngInfiniteScroll) | ||
|
||
ngInfiniteScroll is a directive for [AngularJS](http://angularjs.org/) to evaluate an expression when the bottom of the directive's element approaches the bottom of the browser window, which can be used to implement infinite scrolling. | ||
|
||
Demos | ||
----- | ||
|
||
Check out the running demos [at the ngInfiniteScroll web site](http://sroze.github.com/ngInfiniteScroll/demos.html). | ||
|
||
Version Numbers | ||
--------------- | ||
|
||
ngInfinite Scroll follows [semantic versioning](http://semver.org/) and uses the following versioning scheme: | ||
|
||
* Versions starting with 0 (e.g. 0.1.0, 0.2.0, etc.) are for initial development, and the API is not stable | ||
* Versions with an even minor version (1.0.0, 1.4.0, 2.2.0, etc.) are stable releases | ||
* Versions with an odd minor version (1.1.0, 1.3.0, 2.1.0, etc.) are development releases | ||
|
||
The [download page](http://sroze.github.com/ngInfiniteScroll/#download) allows you to pick among various versions and specify which releases are stable (not including pre-release builds). | ||
|
||
Getting Started | ||
--------------- | ||
|
||
* Download ngInfiniteScroll from [the download page on the ngInfiniteScroll web site](http://sroze.github.com/ngInfiniteScroll/#download) or install it with: | ||
* [Bower](http://bower.io/) via `bower install ngInfiniteScroll` | ||
* [Nuget](https://www.nuget.org) via `PM> Install-Package ng-infinite-scroll` | ||
* Include the script tag on your page after the AngularJS and jQuery script tags (ngInfiniteScroll requires jQuery to run) | ||
|
||
<script type='text/javascript' src='path/to/jquery.min.js'></script> | ||
<script type='text/javascript' src='path/to/angular.min.js'></script> | ||
<script type='text/javascript' src='path/to/ng-infinite-scroll.min.js'></script> | ||
|
||
* Ensure that your application module specifies `infinite-scroll` as a dependency: | ||
|
||
angular.module('myApplication', ['infinite-scroll']); | ||
|
||
* Use the directive by specifying an `infinite-scroll` attribute on an element. | ||
|
||
<div infinite-scroll="myPagingFunction()" infinite-scroll-distance="3"></div> | ||
|
||
Note that neither the module nor the directive use the `ng` prefix, as that prefix is reserved for the core Angular module. | ||
|
||
Detailed Documentation | ||
---------------------- | ||
|
||
ngInfiniteScroll accepts several attributes to customize the behavior of the directive; detailed instructions can be found [on the ngInfiniteScroll web site](http://sroze.github.com/ngInfiniteScroll/documentation.html). | ||
|
||
Ports | ||
----- | ||
|
||
If you use [AngularDart](https://github.com/angular/angular.dart), Juha Komulainen has [a port of the project](http://pub.dartlang.org/packages/ng_infinite_scroll) you can use. | ||
|
||
License | ||
------- | ||
|
||
ngInfiniteScroll is licensed under the MIT license. See the LICENSE file for more details. | ||
|
||
Testing | ||
------- | ||
|
||
ngInfiniteScroll uses Protractor for testing. Note that you will need to have Chrome browser, and the `grunt-cli` npm package installed globally if you wish to use grunt (`npm install -g grunt-cli`). Then, install the dependencies with `npm install`. | ||
|
||
* `grunt test:protractor-local` - run tests | ||
|
||
Thank you very much @pomerantsev for your work on these Protractor tests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "ngInfiniteScroll", | ||
"main": "build/ng-infinite-scroll.js", | ||
"ignore": [ | ||
"**/.*", | ||
"_*", | ||
"node_modules", | ||
"compile", | ||
"test", | ||
"Gruntfile.coffee", | ||
".*" | ||
], | ||
"dependencies": { | ||
"angular": ">=1.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
/* ng-infinite-scroll - v1.2.0 - 2015-12-02 */ | ||
var mod; | ||
|
||
mod = angular.module('infinite-scroll', []); | ||
|
||
mod.value('THROTTLE_MILLISECONDS', null); | ||
|
||
mod.directive('infiniteScroll', [ | ||
'$rootScope', '$window', '$interval', 'THROTTLE_MILLISECONDS', function($rootScope, $window, $interval, THROTTLE_MILLISECONDS) { | ||
return { | ||
scope: { | ||
infiniteScroll: '&', | ||
infiniteScrollContainer: '=', | ||
infiniteScrollDistance: '=', | ||
infiniteScrollDisabled: '=', | ||
infiniteScrollUseDocumentBottom: '=', | ||
infiniteScrollListenForEvent: '@' | ||
}, | ||
link: function(scope, elem, attrs) { | ||
var changeContainer, checkInterval, checkWhenEnabled, container, handleInfiniteScrollContainer, handleInfiniteScrollDisabled, handleInfiniteScrollDistance, handleInfiniteScrollUseDocumentBottom, handler, height, immediateCheck, offsetTop, pageYOffset, scrollDistance, scrollEnabled, throttle, unregisterEventListener, useDocumentBottom, windowElement; | ||
windowElement = angular.element($window); | ||
scrollDistance = null; | ||
scrollEnabled = null; | ||
checkWhenEnabled = null; | ||
container = null; | ||
immediateCheck = true; | ||
useDocumentBottom = false; | ||
unregisterEventListener = null; | ||
checkInterval = false; | ||
height = function(elem) { | ||
elem = elem[0] || elem; | ||
if (isNaN(elem.offsetHeight)) { | ||
return elem.document.documentElement.clientHeight; | ||
} else { | ||
return elem.offsetHeight; | ||
} | ||
}; | ||
offsetTop = function(elem) { | ||
if (!elem[0].getBoundingClientRect || elem.css('none')) { | ||
return; | ||
} | ||
return elem[0].getBoundingClientRect().top + pageYOffset(elem); | ||
}; | ||
pageYOffset = function(elem) { | ||
elem = elem[0] || elem; | ||
if (isNaN(window.pageYOffset)) { | ||
return elem.document.documentElement.scrollTop; | ||
} else { | ||
return elem.ownerDocument.defaultView.pageYOffset; | ||
} | ||
}; | ||
handler = function() { | ||
var containerBottom, containerTopOffset, elementBottom, remaining, shouldScroll; | ||
if (container === windowElement) { | ||
containerBottom = height(container) + pageYOffset(container[0].document.documentElement); | ||
elementBottom = offsetTop(elem) + height(elem); | ||
} else { | ||
containerBottom = height(container); | ||
containerTopOffset = 0; | ||
if (offsetTop(container) !== void 0) { | ||
containerTopOffset = offsetTop(container); | ||
} | ||
elementBottom = offsetTop(elem) - containerTopOffset + height(elem); | ||
} | ||
if (useDocumentBottom) { | ||
elementBottom = height((elem[0].ownerDocument || elem[0].document).documentElement); | ||
} | ||
remaining = elementBottom - containerBottom; | ||
shouldScroll = remaining <= height(container) * scrollDistance + 1; | ||
if (shouldScroll) { | ||
checkWhenEnabled = true; | ||
if (scrollEnabled) { | ||
if (scope.$$phase || $rootScope.$$phase) { | ||
return scope.infiniteScroll(); | ||
} else { | ||
return scope.$apply(scope.infiniteScroll); | ||
} | ||
} | ||
} else { | ||
if (checkInterval) { | ||
$interval.cancel(checkInterval); | ||
} | ||
return checkWhenEnabled = false; | ||
} | ||
}; | ||
throttle = function(func, wait) { | ||
var later, previous, timeout; | ||
timeout = null; | ||
previous = 0; | ||
later = function() { | ||
var context; | ||
previous = new Date().getTime(); | ||
$interval.cancel(timeout); | ||
timeout = null; | ||
func.call(); | ||
return context = null; | ||
}; | ||
return function() { | ||
var now, remaining; | ||
now = new Date().getTime(); | ||
remaining = wait - (now - previous); | ||
if (remaining <= 0) { | ||
clearTimeout(timeout); | ||
$interval.cancel(timeout); | ||
timeout = null; | ||
previous = now; | ||
return func.call(); | ||
} else { | ||
if (!timeout) { | ||
return timeout = $interval(later, remaining, 1); | ||
} | ||
} | ||
}; | ||
}; | ||
if (THROTTLE_MILLISECONDS != null) { | ||
handler = throttle(handler, THROTTLE_MILLISECONDS); | ||
} | ||
scope.$on('$destroy', function() { | ||
container.unbind('scroll', handler); | ||
if (unregisterEventListener != null) { | ||
unregisterEventListener(); | ||
return unregisterEventListener = null; | ||
} | ||
}); | ||
handleInfiniteScrollDistance = function(v) { | ||
return scrollDistance = parseFloat(v) || 0; | ||
}; | ||
scope.$watch('infiniteScrollDistance', handleInfiniteScrollDistance); | ||
handleInfiniteScrollDistance(scope.infiniteScrollDistance); | ||
handleInfiniteScrollDisabled = function(v) { | ||
scrollEnabled = !v; | ||
if (scrollEnabled && checkWhenEnabled) { | ||
checkWhenEnabled = false; | ||
return handler(); | ||
} | ||
}; | ||
scope.$watch('infiniteScrollDisabled', handleInfiniteScrollDisabled); | ||
handleInfiniteScrollDisabled(scope.infiniteScrollDisabled); | ||
handleInfiniteScrollUseDocumentBottom = function(v) { | ||
return useDocumentBottom = v; | ||
}; | ||
scope.$watch('infiniteScrollUseDocumentBottom', handleInfiniteScrollUseDocumentBottom); | ||
handleInfiniteScrollUseDocumentBottom(scope.infiniteScrollUseDocumentBottom); | ||
changeContainer = function(newContainer) { | ||
if (container != null) { | ||
container.unbind('scroll', handler); | ||
} | ||
container = newContainer; | ||
if (newContainer != null) { | ||
return container.bind('scroll', handler); | ||
} | ||
}; | ||
changeContainer(windowElement); | ||
if (scope.infiniteScrollListenForEvent) { | ||
unregisterEventListener = $rootScope.$on(scope.infiniteScrollListenForEvent, handler); | ||
} | ||
handleInfiniteScrollContainer = function(newContainer) { | ||
if ((newContainer == null) || newContainer.length === 0) { | ||
return; | ||
} | ||
if (newContainer instanceof HTMLElement) { | ||
newContainer = angular.element(newContainer); | ||
} else if (typeof newContainer.append === 'function') { | ||
newContainer = angular.element(newContainer[newContainer.length - 1]); | ||
} else if (typeof newContainer === 'string') { | ||
newContainer = angular.element(document.querySelector(newContainer)); | ||
} | ||
if (newContainer != null) { | ||
return changeContainer(newContainer); | ||
} else { | ||
throw new Exception("invalid infinite-scroll-container attribute."); | ||
} | ||
}; | ||
scope.$watch('infiniteScrollContainer', handleInfiniteScrollContainer); | ||
handleInfiniteScrollContainer(scope.infiniteScrollContainer || []); | ||
if (attrs.infiniteScrollParent != null) { | ||
changeContainer(angular.element(elem.parent())); | ||
} | ||
if (attrs.infiniteScrollImmediateCheck != null) { | ||
immediateCheck = scope.$eval(attrs.infiniteScrollImmediateCheck); | ||
} | ||
return checkInterval = $interval((function() { | ||
if (immediateCheck) { | ||
return handler(); | ||
} | ||
}), 0); | ||
} | ||
}; | ||
} | ||
]); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"name": "ng-infinite-scroll", | ||
"version": "1.2.0", | ||
"description": "Infinite scrolling for AngularJS", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/sroze/ngInfiniteScroll.git" | ||
}, | ||
"browser": "build/ng-infinite-scroll.js", | ||
"scripts": { | ||
"test": "grunt test:protractor-local" | ||
}, | ||
"author": { | ||
"name": "Brandon Tilley", | ||
"email": "brandon@brandontilley.com", | ||
"url": "http://brandontilley.com" | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "Samuel ROZE", | ||
"email": "samuel.roze@gmail.com", | ||
"url": "http://sroze.io" | ||
} | ||
], | ||
"license": "MIT", | ||
"readmeFilename": "README.md", | ||
"devDependencies": { | ||
"coffee-script": "~1.8.0", | ||
"grunt": "~0.4.5", | ||
"grunt-coffeelint": "~0.0.13", | ||
"grunt-contrib-clean": "~0.6.0", | ||
"grunt-contrib-coffee": "~0.12.0", | ||
"grunt-contrib-concat": "~0.5.0", | ||
"grunt-contrib-connect": "0.8.0", | ||
"grunt-contrib-uglify": "~0.6.0", | ||
"grunt-protractor-runner": "1.1.4", | ||
"mkdirp": "0.5.0", | ||
"protractor": "1.4.0", | ||
"sauce-connect-launcher": "0.9.0" | ||
} | ||
} |
Oops, something went wrong.