Skip to content

Commit

Permalink
First commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
ve3 committed Feb 23, 2021
0 parents commit ed1c483
Show file tree
Hide file tree
Showing 8 changed files with 731 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Line ending normalization. -------------------------
# Reference https://help.github.com/articles/dealing-with-line-endings/
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Explicitly declare text files you want to always be normalized and converted to native line endings on checkout.
*.inc text
*.ini text
*.txt text
*.xml text

# Declare files that will always have LF line endings on checkout.
.htaccess text eol=lf
*.css text eol=lf
*.htm text eol=lf
*.html text eol=lf
*.js text eol=lf
*.json text eol=lf
*.map text eol=lf
*.md text eol=lf
*.mo text eol=lf
*.php text eol=lf
*.po text eol=lf
*.pot text eol=lf
*.sql text eol=lf
*.svg text eol=lf
*.yml text eol=lf

# Denote all files that are truly binary and should not be modified.
*.eot binary
*.gif binary
*.ico binary
*.jpeg binary
*.jpg binary
*.mp3 binary
*.mp4 binary
*.otf binary
*.png binary
*.swf binary
*.ttf binary
*.wav binary
*.woff binary
*.woff2 binary
# End line ending normalization. ----------------------

# Export ignore folders, files.
.dev-notes export-ignore
.gitattributes export-ignore
.gitignore export-ignore
node_modules export-ignore
gulpfile.js export-ignore
package.json export-ignore
package-lock.json export-ignore
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) Rundiz.com

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.
27 changes: 27 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "rundizscrollpagination",
"version": "0.0.1",
"description": "Scroll down the page and automatically call to get next page contents.",
"main": "index.js",
"directories": {
"test": "tests"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Rundiz/RundizScrollPagination.git"
},
"keywords": [
"scroll",
"pagination",
"infinite"
],
"author": "Vee W.",
"license": "MIT",
"bugs": {
"url": "https://github.com/Rundiz/RundizScrollPagination/issues"
},
"homepage": "https://github.com/Rundiz/RundizScrollPagination#readme"
}
62 changes: 62 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Rundiz Scroll Pagination

Scroll down the page and automatically call to get next page contents.

## Features
* Scroll down and auto make AJAX call to get next page contents.
* Can replace current URL in case you hit back or reload and it will be continue from current start offset. (Can be disable via option.)
* There are events to use for custom render HTML elements.
* Hide all children elements that are outside of visible area to improve performance.

### Example:
```html
<div id="posts-container" class="posts-container"></div>

<script src="../../RundizScrollPagination.js" type="application/javascript"></script>
<script type="application/javascript">
// on window dom loaded.
window.addEventListener('DOMContentLoaded', (event) => {
// listen on ajax failed, done to render items.
document.addEventListener('rdScrollPagination.start', (ajaxEvent) => {
const loadingHtml = '<p class="item-loading">Loading &hellip;</p>';
document.querySelector('#posts-container').insertAdjacentHTML('beforeend', loadingHtml);
});
document.addEventListener('rdScrollPagination.fail', (ajaxEvent) => {
let loadingElement = document.querySelector('.item-loading');
if (loadingElement) {
loadingElement.remove();
}
});
document.addEventListener('rdScrollPagination.done', (ajaxEvent) => {
let loadingElement = document.querySelector('.item-loading');
if (loadingElement) {
loadingElement.remove();
}
let response = (ajaxEvent.detail ? ajaxEvent.detail.response : {});
let listHtml = '';
if (response.items) {
response.items.forEach((item, index) => {
listHtml += '<div class="each-post-item"><p>' + item + '</p></div>';
});
}
document.querySelector('#posts-container')
.insertAdjacentHTML('beforeend', listHtml);
});
// initialize new scroll pagination class.
let scrollPaginationClass = new RundizScrollPagination({
'containerSelector': '#posts-container',
'childrenItemSelector': '.each-post-item',
'changeURL': true,
'ajaxUrl': 'pagination-dummydata.php?start=%startoffset%'
});
// invoke/run the class.
scrollPaginationClass.invoke();
});
</script>
```

See more options inside class `constructor()`.
Loading

0 comments on commit ed1c483

Please sign in to comment.