diff --git a/src/routes/hedge-funds/[slug]/+page.svelte b/src/routes/hedge-funds/[slug]/+page.svelte index e14a54c2..9fb83892 100644 --- a/src/routes/hedge-funds/[slug]/+page.svelte +++ b/src/routes/hedge-funds/[slug]/+page.svelte @@ -269,11 +269,7 @@ onMount(async () => { } } -//This function is needed to set currentPage to 1 again when switching from stocks to options. -function tabFunction(state) { - currentPage = 1; - changeAssetType = state; -} + $: { if(changeAssetType && typeof window !== 'undefined') { diff --git a/src/routes/ipos/+page.svelte b/src/routes/ipos/+page.svelte index 3a42f706..0a003288 100644 --- a/src/routes/ipos/+page.svelte +++ b/src/routes/ipos/+page.svelte @@ -2,10 +2,7 @@ import { goto } from '$app/navigation'; import {formatString, abbreviateNumber} from '$lib/utils'; import { screenWidth } from '$lib/store'; - import ScrollToTop from '$lib/components/ScrollToTop.svelte'; - import { fly } from 'svelte/transition'; - - import InfiniteLoading from '$lib/components/InfiniteLoading.svelte'; + import { onMount } from 'svelte'; export let data; @@ -13,29 +10,31 @@ let ipoList; let isLoaded = false; - async function infiniteHandler({ detail: { loaded, complete } }) - { - - if (ipoList?.length === rawData?.length) { - complete(); - } - else { - const nextIndex = ipoList?.length; - const newHoldings = rawData?.slice(nextIndex, nextIndex + 50); - ipoList = [...ipoList, ...newHoldings]; - loaded(); + async function handleScroll() { + const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height + const isBottom = window.innerHeight + window.scrollY >= scrollThreshold; + if (isBottom && ipoList?.length !== rawData?.length) { + const nextIndex = ipoList?.length; + const filteredNewResults = rawData?.slice(nextIndex, nextIndex + 50); + ipoList = [...ipoList, ...filteredNewResults]; } - } - - $: { - if(typeof window !== 'undefined') - { - isLoaded = false; - rawData = data?.getIPOCalendar; - ipoList= rawData?.slice(0,50); - isLoaded = true; } - } + + + onMount( () => { + rawData = data?.getIPOCalendar; + ipoList= rawData?.slice(0,50); + + isLoaded = true; + + window.addEventListener('scroll', handleScroll); + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }) + + + let charNumber = 40; $: { @@ -53,7 +52,7 @@ -
+
@@ -66,17 +65,17 @@ All {rawData?.length} IPOs on the US stock market in between 2019 - 2024. - - {#if $screenWidth > 640} + +
- - - - - - + + + + + + @@ -84,42 +83,34 @@ goto("/stocks/"+item?.symbol)} class="sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] odd:bg-[#27272A] border-b-[#09090B] shake-ticker cursor-pointer"> - - - - - - -
IPO DateNameIPO PriceCurrent PriceReturn SinceIPO DateSymbolNameIPO PriceCurrent PriceReturn Since
+ {new Date(item?.date)?.toLocaleString('en-US', { month: 'short', day: 'numeric', year: 'numeric', daySuffix: '2-digit' })} {item?.symbol} - -
-
- {item?.symbol} - {item?.name?.length > charNumber ? formatString(item?.name?.slice(0,charNumber)) + "..." : formatString(item?.name)} -
-
+
+ {item?.name?.length > charNumber ? formatString(item?.name?.slice(0,charNumber)) + "..." : formatString(item?.name)} + {item?.ipoPrice !== null ? '$'+item?.ipoPrice : '-'} + {item?.currentPrice !== null ? '$'+item?.currentPrice : '-'} + {#if item?.return >=0 && item?.return !== null} - {abbreviateNumber(item?.return)}% {:else if item?.return < 0 && item?.return !== null} - {abbreviateNumber(item?.return)}% {:else} @@ -136,90 +127,11 @@
- +
- {:else} - -
- {#each ipoList as item} -
-
- - -
- IPO Date - - {item?.date !== null ? new Date(item?.date)?.toLocaleString('en-US', { month: 'short', day: 'numeric', year: 'numeric', daySuffix: '2-digit' }) : '-'} - -
-
-
- -
-
- IPO Price - - {item?.ipoPrice !== null ? '$'+item?.ipoPrice : '-'} - -
- -
- Current Price - - {item?.currentPrice !== null ? '$'+item?.currentPrice : '-'} - -
-
- -
- - -
-
- Market Cap - - {item?.marketCap !== null ? abbreviateNumber(item?.marketCap,true) : '-'} - -
- -
- Return - -
- {#if item?.return >=0 && item?.return !== null} - - +{item?.return?.toFixed(2)}% - {:else if item?.return < 0 && item?.return !== null} - - {item?.return?.toFixed(2)}% - {:else} - - - - - {/if} -
-
-
-
- - -
- {/each} - - - - - -
- - - {/if} +