Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kinda infinite-scrolling #15

Closed
wants to merge 1 commit into from
Closed

kinda infinite-scrolling #15

wants to merge 1 commit into from

Conversation

Shiroifuyu
Copy link
Collaborator

Javascript isn't my strong but here are some ideas of a wanky infinite scrolling implementation.

Copy link
Owner

@KeziahMoselle KeziahMoselle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @Shiroifuyu !
Thank's for your PR and your interest in this project !
This is a sufficient infinite scroll functionnality (missing a loading animation for example), and it should be fairly easy to remove jQuery as a dependance too !

<script src="./renderer.js"></script>
<script>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this too

@@ -1,3 +1,4 @@
var currentURL='';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable you created is not used, so you can remove it too :)

@@ -511,6 +513,7 @@ function emptyContainer()
while (container.firstChild)
{
container.removeChild(container.firstChild);
pid = 1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cause a problem with the pagination : see here preview

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I was trying to do was that, if you use infinite-scrolling lets say you end up on page 10 then when you select the Top section in the lateral navbar the page won't restart the pagination.

@@ -469,6 +470,7 @@ function getResults(url)
return;
}
})
currentURL = url;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What did you want to do here ?

@KeziahMoselle
Copy link
Owner

Here is the equivalent of your jQuery code :

let  windowElement = window.window,
     documentElement = document.documentElement;

windowElement.addEventListener('scroll', () => {
  if (windowElement.scrollY >= documentElement.scrollHeight - windowElement.innerHeight - 0.1) {
    showLoading();
    hideLoading();
    let url = getUrl(tags, imgLimit, rating);
    getResults(url + `&pid=${pid}`);
    pid++;
    displayPid.innerHTML = `Page ${pid}`;
  }
});

And it works without jQuery now

@Shiroifuyu
Copy link
Collaborator Author

Thank you so much for taking the time and answering my silly mistakes, I'm still learning Javascript so I appreciate the input very much. Will try to help as much as I can with this project.

@KeziahMoselle
Copy link
Owner

No problem ! I'm glad you want to help to this project 🎉
I'm learning too, so it's spaghetti JS actually !
I will do my best to help you as much as I can

@KeziahMoselle KeziahMoselle added the feature Request feature label Sep 26, 2018
@KeziahMoselle KeziahMoselle added this to the 1.0.0 milestone Sep 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Request feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants