Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/schibsted-tech-polska/ad_refresher
Library that emits event when html element is below or above current screen
https://github.com/schibsted-tech-polska/ad_refresher
Last synced: 3 days ago
JSON representation
Library that emits event when html element is below or above current screen
- Host: GitHub
- URL: https://github.com/schibsted-tech-polska/ad_refresher
- Owner: Schibsted-Tech-Polska
- Created: 2016-02-11T08:22:55.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-02T14:40:17.000Z (almost 2 years ago)
- Last Synced: 2024-11-08T20:32:12.968Z (6 days ago)
- Language: JavaScript
- Homepage:
- Size: 123 KB
- Stars: 1
- Watchers: 8
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ad Refresher library
Proudly developed by Stavanger Aftenblad team in Cracow.
It allows you to load element content, when user scrolls down and is close to display element.
Additional event is emitted, when user scrolls up - it allows you to refresh element content.
## Usage
`$element` should be a DOM Element or a jQuery object.
```
var $element = $(this); // or document.getElementById('elementId');$ad.on('load-ad', function() {
// your callback for loading element, i.e.
loadContent($element);
});
$ad.on('reload-ad', function() {
// your callback for reloading element, i.e.
reloadContent($element);
});
// default options
var options = {
loadingThreshold: 300,
reloadingThreshold: 150,
useReloading: true // if set to false, it will disable reload event
}// second parameter is optional
AdRefresher.init($element, options);
```## Development
```
git clone https://github.com/aftenbladet/ad_refresher.git
cd ad_refresher
npm install
```Fill in your changes. And prepare dist:
```
gulp prepare-dist
```And make a PR :)