@egjs/svelte-infinitegrid 3.2.5 → 4.0.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/main.js +32 -0
- package/.storybook/manager.js +5 -0
- package/.storybook/preview.js +25 -0
- package/README.md +79 -155
- package/dist/infinitegrid.cjs.js +203 -533
- package/dist/infinitegrid.cjs.js.map +1 -1
- package/dist/infinitegrid.esm.js +198 -522
- package/dist/infinitegrid.esm.js.map +1 -1
- package/global.d.ts +8 -0
- package/package.json +41 -50
- package/public/global.css +6 -5
- package/public/index.html +3 -3
- package/rollup.config.js +7 -6
- package/src/InfiniteGrid.js +23 -16
- package/src/InfiniteGrid.svelte +91 -138
- package/src/consts.js +8 -13
- package/src/grids/FrameInfiniteGrid.js +17 -0
- package/src/grids/JustifiedInfiniteGrid.js +17 -0
- package/src/grids/MasonryInfiniteGrid.js +17 -0
- package/src/grids/PackingInfiniteGrid.js +17 -0
- package/src/index.d.ts +14 -27
- package/src/index.js +5 -13
- package/src/index.umd.js +2 -6
- package/src/{demo/main.js → main.ts} +1 -1
- package/stories/1-MasonryInfiniteGrid/0-MasonryInfiniteGrid.stories.ts +4 -0
- package/stories/1-MasonryInfiniteGrid/1-MasonryInfiniteGrid.stories.ts +27 -0
- package/stories/1-MasonryInfiniteGrid/apps/SvelteMasonryInfiniteGridApp.svelte +42 -0
- package/stories/2-JustifiedInfiniteGrid/0-JustifiedInfiniteGrid.stories.ts +5 -0
- package/stories/2-JustifiedInfiniteGrid/1-JustifiedInfiniteGrid.stories.ts +10 -0
- package/stories/2-JustifiedInfiniteGrid/apps/SvelteJustifiedInfiniteGridApp.svelte +43 -0
- package/stories/3-FrameInfiniteGrid/0-FrameInfiniteGrid.stories.ts +5 -0
- package/stories/3-FrameInfiniteGrid/1-FrameInfiniteGrid.stories.ts +10 -0
- package/stories/3-FrameInfiniteGrid/apps/SvelteFrameInfiniteGridApp.svelte +44 -0
- package/stories/4-PackingInfiniteGrid/0-PackingInfiniteGrid.stories.ts +5 -0
- package/stories/4-PackingInfiniteGrid/1-PackingInfiniteGrid.stories.ts +10 -0
- package/stories/4-PackingInfiniteGrid/apps/SveltePackingInfiniteGridApp.svelte +40 -0
- package/stories/5-DataLoading/0-DataLoading.stories.ts +7 -0
- package/stories/5-DataLoading/1-WaitNReady.stories.ts +10 -0
- package/stories/5-DataLoading/2-Placeholder.stories.ts +10 -0
- package/stories/5-DataLoading/3-Loading.stories.ts +10 -0
- package/stories/5-DataLoading/apps/SvelteLoadingApp.svelte +54 -0
- package/stories/5-DataLoading/apps/SveltePlaceholderApp.svelte +54 -0
- package/stories/5-DataLoading/apps/SvelteWaitNReadyApp.svelte +47 -0
- package/tsconfig.json +4 -61
- package/.editorconfig +0 -3
- package/LICENSE +0 -19
- package/babel.config.js +0 -10
- package/jest.config.js +0 -14
- package/rollup_start_dev.js +0 -12
- package/src/LoadingChecker.svelte +0 -9
- package/src/demo/App.svelte +0 -86
- package/src/demo/useFirstRender.svelte +0 -67
- package/src/layouts/FrameLayout.js +0 -9
- package/src/layouts/GridLayout.js +0 -9
- package/src/layouts/JustifiedLayout.js +0 -9
- package/src/layouts/PackingLayout.js +0 -9
- package/src/layouts/SquareLayout.js +0 -9
- package/svelte.config.js +0 -5
- package/test/unit/demo.spec.ts +0 -23
package/.editorconfig
DELETED
package/LICENSE
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2019-present NAVER Corp.
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
in the Software without restriction, including without limitation the rights
|
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
furnished to do so, subject to the following conditions:
|
|
9
|
-
|
|
10
|
-
The above copyright notice and this permission notice shall be included in
|
|
11
|
-
all copies or substantial portions of the Software.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
THE SOFTWARE.
|
package/babel.config.js
DELETED
package/jest.config.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
testMatch: ["<rootDir>/test/unit/**/*.spec.ts"],
|
|
3
|
-
transform: {
|
|
4
|
-
"^.+\\.svelte$": [
|
|
5
|
-
"svelte-jester",
|
|
6
|
-
{
|
|
7
|
-
preprocess: true,
|
|
8
|
-
},
|
|
9
|
-
],
|
|
10
|
-
"^.+\\.js$": "babel-jest",
|
|
11
|
-
"^.+\\.ts$": "ts-jest",
|
|
12
|
-
},
|
|
13
|
-
moduleFileExtensions: ["ts", "js", "svelte"],
|
|
14
|
-
};
|
package/rollup_start_dev.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as child_process from 'child_process';
|
|
2
|
-
|
|
3
|
-
let running_dev_server = false;
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
writeBundle() {
|
|
7
|
-
if (!running_dev_server) {
|
|
8
|
-
running_dev_server = true;
|
|
9
|
-
child_process.spawn('npm', ['run', 'start:dev'], { stdio: ['ignore', 'inherit', 'inherit'], shell: true });
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
};
|
package/src/demo/App.svelte
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import InfinitGrid from "../index.js";
|
|
3
|
-
let ig;
|
|
4
|
-
let items = [];
|
|
5
|
-
let loading;
|
|
6
|
-
|
|
7
|
-
function loadItems(groupKey, nextKey, itemCount) {
|
|
8
|
-
const nextItems = [];
|
|
9
|
-
|
|
10
|
-
for (let i = 0; i < itemCount; ++i) {
|
|
11
|
-
nextItems.push({ groupKey, key: nextKey + i });
|
|
12
|
-
}
|
|
13
|
-
return nextItems;
|
|
14
|
-
}
|
|
15
|
-
function onAppend({ detail: { groupKey, startLoading } }) {
|
|
16
|
-
if (ig.isProcessing()) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
startLoading();
|
|
20
|
-
const nextGroupKey = (parseFloat(groupKey) || 0) + 1;
|
|
21
|
-
const nextKey = items.length;
|
|
22
|
-
|
|
23
|
-
items = [...items, ...loadItems(nextGroupKey, nextKey, 10)];
|
|
24
|
-
}
|
|
25
|
-
function onLayoutComplete({ detail: { isLayout, endLoading } }) {
|
|
26
|
-
!isLayout && endLoading();
|
|
27
|
-
}
|
|
28
|
-
</script>
|
|
29
|
-
|
|
30
|
-
<style>
|
|
31
|
-
.item {
|
|
32
|
-
width: 250px;
|
|
33
|
-
opacity: 1;
|
|
34
|
-
}
|
|
35
|
-
.item .thumbnail {
|
|
36
|
-
max-height: 300px;
|
|
37
|
-
overflow: hidden;
|
|
38
|
-
border-radius: 8px;
|
|
39
|
-
}
|
|
40
|
-
.item .thumbnail img {
|
|
41
|
-
width: 100%;
|
|
42
|
-
border-radius: 8px;
|
|
43
|
-
}
|
|
44
|
-
.item .info {
|
|
45
|
-
margin-top: 10px;
|
|
46
|
-
font-weight: bold;
|
|
47
|
-
color: #777;
|
|
48
|
-
}
|
|
49
|
-
.item.animate {
|
|
50
|
-
transition: opacity ease 1s;
|
|
51
|
-
transition-delay: 0.2s;
|
|
52
|
-
opacity: 1;
|
|
53
|
-
}
|
|
54
|
-
.loading {
|
|
55
|
-
position: absolute;
|
|
56
|
-
width: 100%;
|
|
57
|
-
height: 50px;
|
|
58
|
-
line-height: 50px;
|
|
59
|
-
text-align: center;
|
|
60
|
-
font-weight: bold;
|
|
61
|
-
}
|
|
62
|
-
</style>
|
|
63
|
-
|
|
64
|
-
<InfinitGrid
|
|
65
|
-
bind:this={ig}
|
|
66
|
-
{items}
|
|
67
|
-
{loading}
|
|
68
|
-
itemBy={item => item.key}
|
|
69
|
-
groupBy={item => item.groupKey}
|
|
70
|
-
options={{ isConstantSize: true, transitionDuration: 0.2 }}
|
|
71
|
-
layoutOptions={{ margin: 10, align: 'center' }}
|
|
72
|
-
on:append={onAppend}
|
|
73
|
-
on:layoutComplete={onLayoutComplete}
|
|
74
|
-
let:visibleItems>
|
|
75
|
-
{#each visibleItems as item (item.key)}
|
|
76
|
-
<div class="item">
|
|
77
|
-
<div class="thumbnail">
|
|
78
|
-
<img
|
|
79
|
-
src={`https://naver.github.io/egjs-infinitegrid/assets/image/${(item.key % 59) + 1}.jpg`}
|
|
80
|
-
alt="egjs" />
|
|
81
|
-
</div>
|
|
82
|
-
<div class="info">{`egjs ${item.key}`}</div>
|
|
83
|
-
</div>
|
|
84
|
-
{/each}
|
|
85
|
-
<div bind:this={loading} slot="loading">Loading</div>
|
|
86
|
-
</InfinitGrid>
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import InfinitGrid from "../index.js";
|
|
3
|
-
|
|
4
|
-
const items = [
|
|
5
|
-
{
|
|
6
|
-
groupKey: 1,
|
|
7
|
-
key: 1,
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
groupKey: 2,
|
|
11
|
-
key: 2,
|
|
12
|
-
},
|
|
13
|
-
];
|
|
14
|
-
</script>
|
|
15
|
-
|
|
16
|
-
<style>
|
|
17
|
-
.item {
|
|
18
|
-
width: 250px;
|
|
19
|
-
opacity: 1;
|
|
20
|
-
}
|
|
21
|
-
.item .thumbnail {
|
|
22
|
-
max-height: 300px;
|
|
23
|
-
overflow: hidden;
|
|
24
|
-
border-radius: 8px;
|
|
25
|
-
}
|
|
26
|
-
.item .thumbnail img {
|
|
27
|
-
width: 100%;
|
|
28
|
-
border-radius: 8px;
|
|
29
|
-
}
|
|
30
|
-
.item .info {
|
|
31
|
-
margin-top: 10px;
|
|
32
|
-
font-weight: bold;
|
|
33
|
-
color: #777;
|
|
34
|
-
}
|
|
35
|
-
.item.animate {
|
|
36
|
-
transition: opacity ease 1s;
|
|
37
|
-
transition-delay: 0.2s;
|
|
38
|
-
opacity: 1;
|
|
39
|
-
}
|
|
40
|
-
.loading {
|
|
41
|
-
position: absolute;
|
|
42
|
-
width: 100%;
|
|
43
|
-
height: 50px;
|
|
44
|
-
line-height: 50px;
|
|
45
|
-
text-align: center;
|
|
46
|
-
font-weight: bold;
|
|
47
|
-
}
|
|
48
|
-
</style>
|
|
49
|
-
<InfinitGrid
|
|
50
|
-
{items}
|
|
51
|
-
itemBy={item => item.key}
|
|
52
|
-
groupBy={item => item.groupKey}
|
|
53
|
-
useFirstRender={true}
|
|
54
|
-
options={{ isConstantSize: true, transitionDuration: 0.2 }}
|
|
55
|
-
layoutOptions={{ margin: 10, align: 'center' }}
|
|
56
|
-
let:visibleItems>
|
|
57
|
-
{#each visibleItems as item (item.key)}
|
|
58
|
-
<div class="item">
|
|
59
|
-
<div class="thumbnail">
|
|
60
|
-
<img
|
|
61
|
-
src={`https://naver.github.io/egjs-infinitegrid/assets/image/${(item.key % 59) + 1}.jpg`}
|
|
62
|
-
alt="egjs" />
|
|
63
|
-
</div>
|
|
64
|
-
<div class="info">{`egjs ${item.key}`}</div>
|
|
65
|
-
</div>
|
|
66
|
-
{/each}
|
|
67
|
-
</InfinitGrid>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import InfiniteGrid from "../InfiniteGrid.svelte";
|
|
2
|
-
import { FrameLayout as layoutType } from "@egjs/infinitegrid";
|
|
3
|
-
|
|
4
|
-
export default class FrameLayout extends InfiniteGrid {
|
|
5
|
-
constructor(options) {
|
|
6
|
-
options.props.layoutType = layoutType;
|
|
7
|
-
super(options);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import InfiniteGrid from "../InfiniteGrid.svelte";
|
|
2
|
-
import { GridLayout as layoutType } from "@egjs/infinitegrid";
|
|
3
|
-
|
|
4
|
-
export default class GridLayout extends InfiniteGrid {
|
|
5
|
-
constructor(options) {
|
|
6
|
-
options.props.layoutType = layoutType;
|
|
7
|
-
super(options);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import InfiniteGrid from "../InfiniteGrid.svelte";
|
|
2
|
-
import { JustifiedLayout as layoutType } from "@egjs/infinitegrid";
|
|
3
|
-
|
|
4
|
-
export default class JustifiedLayout extends InfiniteGrid {
|
|
5
|
-
constructor(options) {
|
|
6
|
-
options.props.layoutType = layoutType;
|
|
7
|
-
super(options);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import InfiniteGrid from "../InfiniteGrid.svelte";
|
|
2
|
-
import { PackingLayout as layoutType } from "@egjs/infinitegrid";
|
|
3
|
-
|
|
4
|
-
export default class PackingLayout extends InfiniteGrid {
|
|
5
|
-
constructor(options) {
|
|
6
|
-
options.props.layoutType = layoutType;
|
|
7
|
-
super(options);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import InfiniteGrid from "../InfiniteGrid.svelte";
|
|
2
|
-
import { SquareLayout as layoutType } from "@egjs/infinitegrid";
|
|
3
|
-
|
|
4
|
-
export default class SquareLayout extends InfiniteGrid {
|
|
5
|
-
constructor(options) {
|
|
6
|
-
options.props.layoutType = layoutType;
|
|
7
|
-
super(options);
|
|
8
|
-
}
|
|
9
|
-
}
|
package/svelte.config.js
DELETED
package/test/unit/demo.spec.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import "@testing-library/jest-dom/extend-expect";
|
|
2
|
-
import {render} from "@testing-library/svelte";
|
|
3
|
-
import App from "../../src/demo/App.svelte";
|
|
4
|
-
import useFirstRender from "../../src/demo/useFirstRender.svelte";
|
|
5
|
-
|
|
6
|
-
describe("test svelte-infinitegrid", () => {
|
|
7
|
-
it("should check if the demo works", () => {
|
|
8
|
-
// Given, When
|
|
9
|
-
render(App);
|
|
10
|
-
|
|
11
|
-
// Then
|
|
12
|
-
// If it works, no error occurs.
|
|
13
|
-
expect(true).toBe(true);
|
|
14
|
-
});
|
|
15
|
-
it("should check if useFirstRender demo works", () => {
|
|
16
|
-
// Given, When
|
|
17
|
-
render(useFirstRender);
|
|
18
|
-
|
|
19
|
-
// Then
|
|
20
|
-
// If it works, no error occurs.
|
|
21
|
-
expect(true).toBe(true);
|
|
22
|
-
});
|
|
23
|
-
});
|