Skip to content
Snippets Groups Projects
demo.html 2.66 KiB
Newer Older
insert's avatar
insert committed
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title>vdynamic-list demo</title>
		<script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>
		<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
		<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet"> 
	</head>
	<body>
		<div id="app">
			<div class="entry header">
				<div>
					<div>Name</div>
					<div>Email</div>
					<div>Notes</div>
					<div class="filler"></div>
				</div>
			</div>
			<dynamic-list ref="myList">
				<template slot="entry" slot-scope="props">
					<div>{{props.entry.name}}</div>
					<div>{{props.entry.email}}</div>
					<div>{{props.entry.notes}}</div>
					<div class="filler"></div>
				</template>
				<template slot="unloaded" slot-scope="props">
					<div><div></div></div>
					<div><div></div></div>
					<div><div></div></div>
					<div class="filler"></div>
				</template>
			</dynamic-list>
		</div>
	</body>
	<script src="index.js"></script>
	<script>
		const app = new Vue({
			el: '#app'
		});

		new vDynamicList(app, {
			ref: 'myList',
			onLoad: (i, l) => {
				return new Promise((resolve, reject) => {
					let y = [];
					for (let j=0;j<l;j++) y.push({name: 'test', email: 'eee', notes: i * l + j});
					setTimeout(() => resolve(y), 400);
				});
			},
			elements: 1400,
			limit: 100
		});
	</script>
	<style>
		html {
			font-family: 'Raleway', sans-serif;
		}
		@keyframes color {
			0% {
				background-color: #22222222;
			}

			50% {
				background-color: #44444444;
			}

			100% {
				background-color: #22222222;
			}
		}
		.header {
			font-size: 1.8em;
		}
		.header div div {
			margin-left: 14px;
			margin-top: 4px;
		}
insert's avatar
insert committed
		.section:not(.loaded) {
insert's avatar
insert committed
			min-height: calc(50px * 100);
		}
		.entry {
			height: 50px;
		}
		.entry > div {
			width: 100%;
		}
		.entry:hover {
			background-color: rgba(150, 150, 150, 0.3);
		}
		.entry > div {
			display: flex;
			flex-direction: row;
		}
		.entry > div div:nth-child(1) {
			flex: 2;
		}
		.entry > div div:nth-child(2) {
			flex: 2;
		}
		.entry > div div:nth-child(3) {
			flex: 4;
		}
		.entry > div div.filler {
insert's avatar
insert committed
			flex: 2;
insert's avatar
insert committed
		}
insert's avatar
insert committed
		.entry .loaded div {
insert's avatar
insert committed
			margin-top: 14px;
			margin-left: 1em;
		}
insert's avatar
insert committed
		.entry .loadbar div div {
insert's avatar
insert committed
			display: relative;
			margin-top: 19px;
			margin-left: 1em;
insert's avatar
insert committed
			width: 50%;
insert's avatar
insert committed
			height: 12px;
			animation-name: color;
			animation-duration: 2s;
			animation-iteration-count: infinite;
		}
	</style>
</html>