import { experimentOn } from '@islavi/ng2-component-lab'; const basicContext = { scrollContainerId: 'scrollContainer', numLines: Array(20).fill(null), hitBottomCount: 0, pageCount: 0, isPageLoading: false, insertPageImmediately: function(pageNum) { const scrollContainerElem: HTMLElement = document.getElementById(this.scrollContainerId); scrollContainerElem.appendChild(document.createElement('hr')); Array(10).fill(null).forEach((_, i) => { const lineElem = document.createElement('div'); lineElem.innerHTML = `Page ${pageNum} - line ${i + 1}`; scrollContainerElem.appendChild(lineElem); }); }, loadPageAsync: function(pageNum, timeout) { return new Promise((resolve) => { setTimeout(() => { this.insertPageImmediately(pageNum); resolve(); }, timeout); }); }, onScrollHitBottom: function() { this.hitBottomCount++; } }; const basicStyle = ` .scroll-container { margin: 12px; border: none; padding: 5px; width: 200px; height: 100px; overflow: auto; font-size: 20px !important; box-shadow: #666 1px 1px 10px; } .example-source { background: #eeeeee; padding: 10px; border: 1px solid #999999; } .example-source pre { overflow: hidden; background: #dddddd; margin-top: 5px; padding: 5px; user-select: text; } `; const makeBasicStyleDistance = (distance: number) => ` .scroll-container::after { display: block; content: ''; height: ${distance}px; background: red; } `; export default experimentOn('Infinite-Scroll') .group("Infinite Scroll",[ { id: 'infiniteScrollUsage', showSource: true, context: Object.assign({}, basicContext), title: 'Infinite scroll usage', description: 'Infinite scroll usage', styles: [basicStyle], template: `
{{onScrollHitBottom}}
{{onScrollHitBottom}}
{{onScrollHitBottom}}
{{onScrollHitBottom}}