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

Only works when width is set [user error] #29

Open
nonetrix opened this issue Jun 1, 2022 · 2 comments
Open

Only works when width is set [user error] #29

nonetrix opened this issue Jun 1, 2022 · 2 comments

Comments

@nonetrix
Copy link

nonetrix commented Jun 1, 2022

For some reason I can only get this to work if I set the height of the container to a amount of px that doesn't take up the full screen 100% doesn't work 999px doesn't work etc

This is most likely a user error but is very confusing and cannot seem to Google or solve myself

<script>
	import {onMount} from "svelte";
	import InfiniteScroll from "svelte-infinite-scroll";

	// let page = 0;
	let data = [];
	let newBatch = [];

	async function fetchData() {
		const response = await fetch("https://yande.re/post.json?limit=20&tags=rating:safe");
		newBatch = await response.json();
		console.log(newBatch)
	};

	onMount(()=> {
		fetchData();
	})

	$: data = [
		...data,
    	...newBatch
  	];
	
</script>

<style>

#container {
    overflow:scroll;
	height: 300px;
}

</style>

<div id="container">
	{#each data as item}
		<img src="{item.preview_url}" alt="asdf"/>
	{/each}
  <InfiniteScroll threshold={100} on:loadMore={() => {fetchData()}}/>
</div>
@andrelmlins
Copy link
Owner

Hi there,

I'm reviewing it here and I'll give you an answer soon.

@leomorpho
Copy link

I am having the same issue. A reasonable solution I found was using height: 100vh;.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants