@html-next/vertical-collection 4.0.1 → 5.0.0

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.
Files changed (39) hide show
  1. package/package.json +64 -79
  2. package/{addon → src}/-private/data-view/elements/occluded-content.js +1 -1
  3. package/{addon/-private/data-view → src/-private/data-view/elements}/viewport-container.js +35 -25
  4. package/{addon → src}/-private/data-view/elements/virtual-component.js +13 -5
  5. package/{addon → src}/-private/data-view/radar/dynamic-radar.js +41 -40
  6. package/{addon → src}/-private/data-view/radar/radar.js +211 -112
  7. package/{addon → src}/-private/data-view/radar/static-radar.js +19 -7
  8. package/{addon → src}/-private/data-view/skip-list.js +20 -21
  9. package/{addon → src}/-private/data-view/utils/insert-range-before.js +6 -1
  10. package/{addon → src}/-private/data-view/utils/mutation-checkers.js +12 -4
  11. package/src/-private/data-view/utils/object-at.js +10 -0
  12. package/{addon → src}/-private/data-view/utils/scroll-handler.js +19 -9
  13. package/{addon → src}/-private/data-view/utils/supports-passive.js +2 -2
  14. package/{addon/-private/data-view/elements → src/-private/data-view}/viewport-container.js +35 -25
  15. package/{addon → src}/-private/ember-internals/key-for-item.js +9 -3
  16. package/{addon → src}/-private/index.js +8 -8
  17. package/{addon → src}/-private/utils/element/closest.js +8 -2
  18. package/{addon → src}/-private/utils/element/estimate-element-height.js +11 -5
  19. package/{addon/components/vertical-collection/component.js → src/components/vertical-collection.gjs} +155 -71
  20. package/src/index.js +3 -0
  21. package/{addon/styles/app.css → src/occluded-content.css} +11 -1
  22. package/.github/workflows/ci.yml +0 -102
  23. package/CHANGELOG.md +0 -167
  24. package/README.md +0 -122
  25. package/RELEASE.md +0 -74
  26. package/addon/-private/data-view/utils/object-at.js +0 -7
  27. package/addon/components/vertical-collection/template.hbs +0 -13
  28. package/app/components/vertical-collection.js +0 -1
  29. package/bin/restore-env.sh +0 -1
  30. package/bin/run-tests-with-retry.sh +0 -24
  31. package/bin/stash-env.sh +0 -1
  32. package/config/ember-cli-toolbelts.json +0 -1
  33. package/config/environment.js +0 -5
  34. package/index.js +0 -161
  35. package/vendor/debug.css +0 -62
  36. /package/{addon → src}/-private/data-view/utils/round-to.js +0 -0
  37. /package/{addon → src}/-private/ember-internals/identity.js +0 -0
  38. /package/{addon → src}/-private/utils/document-shim.js +0 -0
  39. /package/{addon → src}/-private/utils/element/get-scaled-client-rect.js +0 -0
package/README.md DELETED
@@ -1,122 +0,0 @@
1
- # vertical-collection
2
-
3
- [![Greenkeeper badge](https://badges.greenkeeper.io/html-next/vertical-collection.svg)](https://greenkeeper.io/)
4
-
5
- [![Build Status](https://travis-ci.org/html-next/vertical-collection.svg)](https://travis-ci.org/html-next/vertical-collection)
6
-
7
- Infinite Scroll and Occlusion at > 60FPS
8
-
9
- `vertical-collection` is an `ember-addon` that is part of the `smoke-and-mirrors` framework. It
10
- focuses on improving initial and re-render performance in high-stress situations by providing a
11
- component for performant lists and `svelte renders` to match a core belief:
12
- **Don't render the universe, render the scene.**
13
-
14
- #### TL;DR svelte render: the fewer things you need to render, the faster your renders will be.
15
-
16
- Your web page is a universe, your viewport is the scene. Much like you wouldn't expect a video game to render
17
- out-of-scene content, your application should smartly cull the content it doesn't need to care about. Trimming
18
- excess content lets the browser perform both initial renders and re-renders at far higher frame-rates, as the only
19
- content it needs to focus on for layout is the content the user can see.
20
-
21
- `vertical-collection` augments your existing app, it doesn't ask you to rewrite layouts or logic in order to use it.
22
- It will try its best to allow you to keep the conventions, structures, and layouts you want.
23
-
24
- ## Install
25
-
26
- ```bash
27
- ember install @html-next/vertical-collection
28
- ```
29
-
30
- ## Usage
31
-
32
- ```htmlbars
33
- <VerticalCollection
34
- @items={{items}}
35
- @tagName="ul"
36
- @estimateHeight={{50}}
37
- @staticHeight={{false}}
38
- @bufferSize={{1}}
39
- @renderAll={{false}}
40
- @renderFromLast={{false}}
41
- @idForFirstItem={{idForFirstItem}}
42
- @firstReached={{firstReachedCallback}}
43
- @lastReached={{lastReachedCallback}}
44
- @firstVisibleChanged={{firstVisibleChangedCallback}}
45
- @lastVisibleChanged={{lastVisibleChangedCallback}}
46
- as |item i|>
47
- <li>
48
- {{item.number}} {{i}}
49
- </li>
50
- </VerticalCollection>
51
- ```
52
-
53
- ### Actions
54
-
55
- `firstReached` - Triggered when scroll reaches the first element in the collection
56
-
57
- `lastReached`- Triggered when scroll reaches the last element in the collection
58
-
59
- `firstVisibleChanged` - Triggered when the first element in the viewport changes
60
-
61
- `lastVisibleChanged` - Triggered when the last element in the viewport changes
62
-
63
- ## Support Matrix
64
-
65
- | `vertical-collection` version | Supported Ember versions | Supported Node versions |
66
- | ----------------------------- | ------------------------ | ----------------------- |
67
- | `^v1.x.x` | `v1.12.0 - v3.8.x` | `?` |
68
- | `^v2.x.x` | `v2.8.0 - v3.26.x` | `v12 - ?` |
69
- | `^v3.x.x` | `v2.18.0+` | `v14+` |
70
- | `^v4.x.x` | `v3.12.0+` | `v14+` |
71
-
72
- ## Support, Questions, Collaboration
73
-
74
- Join the [Ember community on Discord](https://discord.gg/zT3asNS)
75
-
76
- ## Features
77
-
78
- ### Infinite Scroll (bi-directional)
79
-
80
- Infinite scroll that remains performant even for very long lists is easily achievable
81
- with the [`vertical-collection`](http://html-next.github.io/vertical-collection/#/settings).
82
- It works via a scrollable div or scrollable body.
83
-
84
- - [bi-directional scrollable div](http://html-next.github.io/vertical-collection/#/examples/infinite-scroll)
85
- - [scrollable body](http://html-next.github.io/vertical-collection/#/examples/scrollable-body)
86
- - [dynamic content sizes](http://html-next.github.io/vertical-collection/#/examples/flexible-layout)
87
- - [as a table](http://html-next.github.io/vertical-collection/#/examples/dbmon)
88
-
89
- ### Svelte Everything
90
-
91
- If it can be trimmer, vertical-collection likes to trim it.
92
-
93
- ## Status
94
-
95
- [Changelog](./CHANGELOG.md)
96
-
97
- [![Build Status](https://travis-ci.org/html-next/vertical-collection.svg)](https://travis-ci.org/html-next/vertical-collection)
98
- [![dependencies](https://david-dm.org/html-next/vertical-collection.svg)](https://david-dm.org/html-next/vertical-collection)
99
- [![devDependency Status](https://david-dm.org/html-next/vertical-collection/dev-status.svg)](https://david-dm.org/html-next/vertical-collection#info=devDependencies)
100
- [![Coverage Status](https://coveralls.io/repos/html-next/vertical-collection/badge.svg?branch=master&service=github)](https://coveralls.io/github/html-next/vertical-collection?branch=master)
101
-
102
- ## Documentation
103
-
104
- For updated documentation and demos see [http://html-next.github.io/vertical-collection/](http://html-next.github.io/vertical-collection/)
105
-
106
- ## Contributing
107
-
108
- - Open an Issue for discussion first if you're unsure a feature/fix is wanted.
109
- - Branch off of `master` (default branch)
110
- - Use descriptive branch names (e.g. `<type>/<short-description>`)
111
- - PR against `master` (default branch).
112
-
113
- ### Testing
114
-
115
- Make sure you register the test waiter from [ember-raf-scheduler](https://github.com/html-next/ember-raf-scheduler). So `ember-test-helpers`'s `wait` is aware of the scheduled updates.
116
-
117
- An example can be found [here](https://github.com/html-next/vertical-collection/blob/master/tests/test-helper.js#L2)
118
-
119
- License
120
- ------------------------------------------------------------------------------
121
-
122
- This project is licensed under the [MIT License](LICENSE.md).
package/RELEASE.md DELETED
@@ -1,74 +0,0 @@
1
- # Release Process
2
-
3
- Releases are mostly automated using
4
- [release-it](https://github.com/release-it/release-it/) and
5
- [lerna-changelog](https://github.com/lerna/lerna-changelog/).
6
-
7
- ## Preparation
8
-
9
- Since the majority of the actual release process is automated, the primary
10
- remaining task prior to releasing is confirming that all pull requests that
11
- have been merged since the last release have been labeled with the appropriate
12
- `lerna-changelog` labels and the titles have been updated to ensure they
13
- represent something that would make sense to our users. Some great information
14
- on why this is important can be found at
15
- [keepachangelog.com](https://keepachangelog.com/en/1.0.0/), but the overall
16
- guiding principle here is that changelogs are for humans, not machines.
17
-
18
- When reviewing merged PR's the labels to be used are:
19
-
20
- * breaking - Used when the PR is considered a breaking change.
21
- * enhancement - Used when the PR adds a new feature or enhancement.
22
- * bug - Used when the PR fixes a bug included in a previous release.
23
- * documentation - Used when the PR adds or updates documentation.
24
- * internal - Used for internal changes that still require a mention in the
25
- changelog/release notes.
26
-
27
- ## Release
28
-
29
- Once the prep work is completed, the actual release is straight forward:
30
-
31
- * First, ensure that you have installed your projects dependencies:
32
-
33
- ```sh
34
- yarn install
35
- ```
36
-
37
- * Second, ensure that you have obtained a
38
- [GitHub personal access token][generate-token] with the `repo` scope (no
39
- other permissions are needed). Make sure the token is available as the
40
- `GITHUB_AUTH` environment variable.
41
-
42
- For instance:
43
-
44
- ```bash
45
- export GITHUB_AUTH=abc123def456
46
- ```
47
-
48
- [generate-token]: https://github.com/settings/tokens/new?scopes=repo&description=GITHUB_AUTH+env+variable
49
-
50
- * And last (but not least 😁) do your release.
51
-
52
- ```sh
53
- npx release-it
54
- ```
55
-
56
- [release-it](https://github.com/release-it/release-it/) manages the actual
57
- release process. It will prompt you to to choose the version number after which
58
- you will have the chance to hand tweak the changelog to be used (for the
59
- `CHANGELOG.md` and GitHub release), then `release-it` continues on to tagging,
60
- pushing the tag and commits, etc.
61
-
62
- To start a prerelease branch for a new major use:
63
-
64
- ```sh
65
- npx release-it major --preRelease=beta
66
- ```
67
-
68
- On subsequent prerelease run:
69
-
70
- ```sh
71
- npx release-it --preRelease
72
- ```
73
-
74
- For more guidance see https://github.com/release-it/release-it/blob/master/docs/pre-releases.md
@@ -1,7 +0,0 @@
1
- import { assert } from '@ember/debug';
2
-
3
- export default function objectAt(arr, index) {
4
- assert('arr must be an instance of a Javascript Array or implement `objectAt`', Array.isArray(arr) || typeof arr.objectAt === 'function');
5
-
6
- return arr.objectAt ? arr.objectAt(index) : arr[index];
7
- }
@@ -1,13 +0,0 @@
1
- {{#each this.virtualComponents key="id" as |virtualComponent| ~}}
2
- {{~unbound virtualComponent.upperBound~}}
3
- {{~#if virtualComponent.isOccludedContent ~}}
4
- {{{unbound virtualComponent.element}}}
5
- {{~else~}}
6
- {{~yield virtualComponent.content virtualComponent.index ~}}
7
- {{~/if~}}
8
- {{~unbound virtualComponent.lowerBound~}}
9
- {{~/each}}
10
-
11
- {{#if this.shouldYieldToInverse}}
12
- {{yield to="inverse"}}
13
- {{/if}}
@@ -1 +0,0 @@
1
- export { default } from '@html-next/vertical-collection/components/vertical-collection/component';
@@ -1 +0,0 @@
1
- export EMBER_OPTIONAL_FEATURES=$(cat __env)
@@ -1,24 +0,0 @@
1
- #!/bin/bash
2
-
3
- function retry {
4
- command="$*"
5
- retval=1
6
- attempt=1
7
- until [[ $retval -eq 0 ]] || [[ $attempt -gt 4 ]]; do
8
- # Execute inside of a subshell in case parent
9
- # script is running with "set -e"
10
- (
11
- set +e
12
- $command
13
- )
14
- retval=$?
15
- attempt=$(( $attempt + 1 ))
16
- if [[ $retval -ne 0 ]]; then
17
- # If there was an error wait 10 seconds
18
- sleep 1
19
- fi
20
- done
21
- exit $retval
22
- }
23
-
24
- yarn run ember build && retry yarn run ember test --path=dist
package/bin/stash-env.sh DELETED
@@ -1 +0,0 @@
1
- printf '%s' "$EMBER_OPTIONAL_FEATURES" > __env
@@ -1 +0,0 @@
1
- {}
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = function(/* environment, appConfig */) {
4
- return { };
5
- };
package/index.js DELETED
@@ -1,161 +0,0 @@
1
- 'use strict';
2
-
3
- const StripClassCallCheckPlugin = require.resolve('babel6-plugin-strip-class-callcheck');
4
- const Funnel = require('broccoli-funnel');
5
- const Rollup = require('broccoli-rollup');
6
- const merge = require('broccoli-merge-trees');
7
- const VersionChecker = require('ember-cli-version-checker');
8
-
9
- module.exports = {
10
- name: require('./package').name,
11
-
12
- init() {
13
- this._super.init && this._super.init.apply(this, arguments);
14
-
15
- this.options = this.options || {};
16
- },
17
-
18
- getOutputDirForVersion() {
19
- return '';
20
- },
21
-
22
- // Borrowed from ember-cli-babel
23
- _emberVersionRequiresModulesAPIPolyfill() {
24
- let checker = this.checker.for('ember-source', 'npm');
25
-
26
- if (!checker.exists()) {
27
- return true;
28
- }
29
-
30
- return checker.lt('3.27.0-alpha.1');
31
- },
32
-
33
- treeForAddon(tree) {
34
- let babel = this.addons.find((addon) => addon.name === 'ember-cli-babel');
35
- let withPrivate = new Funnel(tree, { include: ['-private/**'] });
36
- let withoutPrivate = new Funnel(tree, {
37
- exclude: [
38
- '**/**.hbs',
39
- '-private'
40
- ],
41
- destDir: '@html-next/vertical-collection'
42
- });
43
-
44
- // When compiling with `compileModules: false`, ember-cli-babel defaults to
45
- // using the modules polyfill, since it assumes we are concatenating the
46
- // output script using `app.import` without an AMD wrapper.
47
- //
48
- // This does not apply to us, since we are compiling the `-private` modules
49
- // into a single AMD module (via rollup below), which can in fact have
50
- // external dependencies.
51
- //
52
- // We can opt-out of this with `disableEmberModulesAPIPolyfill: true`. In
53
- // Ember versions with "real modules", that is what we want in order to
54
- // avoid the Ember global deprecation (or just completely not working in
55
- // 4.0+).
56
- //
57
- // It seems like the intent may have been that we should be able to set
58
- // this to `true` unconditionally, and `ember-cli-babel` will ignore this
59
- // setting if the Ember verion requires the modules API polyfill. However,
60
- // presumably due to a bug, ember-cli-babel actually checks for this value
61
- // first and return out of the function early if its value is truthy. This
62
- // means that if we set this to true unconditionally, then we would have
63
- // disabled the modules polyfill for Ember versions that needs it, which
64
- // would be incorrect. Therefore, we have to duplicate the detection logic
65
- // here in order to set this value appropriately.
66
- //
67
- // Ideally, we should just stop trying to rollup the -private modules and
68
- // let the modern build pipeline optimizes things for us, then none of this
69
- // would have been necessary.
70
- let privateTree = babel.transpileTree(withPrivate, {
71
- babel: this.options.babel,
72
- 'ember-cli-babel': {
73
- compileModules: false,
74
- disableEmberModulesAPIPolyfill:
75
- !this._emberVersionRequiresModulesAPIPolyfill(),
76
- },
77
- });
78
-
79
- const templateTree = new Funnel(tree, {
80
- include: ['**/**.hbs']
81
- });
82
-
83
- // use the default options
84
- const addonTemplateTree = this._super(templateTree);
85
- let publicTree = babel.transpileTree(withoutPrivate);
86
-
87
- privateTree = new Rollup(privateTree, {
88
- rollup: {
89
- input: '-private/index.js',
90
- output: [
91
- {
92
- file: '@html-next/vertical-collection/-private.js',
93
- format: 'amd',
94
- amd: {
95
- id: '@html-next/vertical-collection/-private'
96
- }
97
- }
98
- ],
99
- external(id) {
100
- return (
101
- id.startsWith('@ember/') ||
102
- ['ember', 'ember-raf-scheduler'].includes(id)
103
- );
104
- },
105
- },
106
- });
107
-
108
- let destDir = this.getOutputDirForVersion();
109
- publicTree = new Funnel(publicTree, { destDir });
110
- privateTree = new Funnel(privateTree, { destDir });
111
-
112
- return merge([
113
- addonTemplateTree,
114
- publicTree,
115
- privateTree
116
- ]);
117
- },
118
-
119
- _hasSetupBabelOptions: false,
120
- buildBabelOptions(originalOptions) {
121
- const plugins = originalOptions.plugins || [];
122
-
123
- const opts = {
124
- loose: true,
125
- plugins,
126
- postTransformPlugins: [[StripClassCallCheckPlugin, {}]]
127
- };
128
-
129
- return opts;
130
- },
131
- _setupBabelOptions() {
132
- if (this._hasSetupBabelOptions) {
133
- return;
134
- }
135
-
136
- this.options.babel = this.buildBabelOptions(this.options.babel);
137
-
138
- this._hasSetupBabelOptions = true;
139
- },
140
-
141
- included(app) {
142
- this._super.included.apply(this, arguments);
143
- this.checker = new VersionChecker(app);
144
-
145
- while (typeof app.import !== 'function' && app.app) {
146
- app = app.app;
147
- }
148
-
149
- if (typeof app.import !== 'function') {
150
- throw new Error('vertical-collection is being used within another addon or engine '
151
- + 'and is having trouble registering itself to the parent application.');
152
- }
153
-
154
- this._env = app.env;
155
- this._setupBabelOptions(app.env);
156
-
157
- if (!/production/.test(app.env) && !/test/.test(app.env)) {
158
- this.import('vendor/debug.css');
159
- }
160
- }
161
- };
package/vendor/debug.css DELETED
@@ -1,62 +0,0 @@
1
- /**!
2
- Visualization Classes for debugging the vertical-collection
3
- */
4
- .vertical-collection-visual-debugger {
5
- height: 100%;
6
- position: fixed;
7
- z-index: 1000;
8
- top: 0;
9
- left: 0;
10
- display: flex;
11
- align-items: center;
12
- justify-content: left;
13
- background: rgba(50, 50, 50, 1);
14
- width: 125px;
15
- }
16
-
17
- .vertical-collection-visual-debugger .vc_visualization-container {
18
- transform: scale(0.25);
19
- left: 0;
20
- position: relative;
21
- }
22
-
23
-
24
- .vertical-collection-visual-debugger .vc_visualization-screen {
25
- position: absolute;
26
- background: transparent;
27
- box-sizing: content-box;
28
- border-top: 2px dashed yellow;
29
- border-bottom: 2px dashed yellow;
30
- width: 500px;
31
- }
32
-
33
- .vertical-collection-visual-debugger .vc_visualization-scroll-container {
34
- position: absolute;
35
- width: 500px;
36
- background: rgba(100, 230, 100, 0.65);
37
- }
38
-
39
- .vertical-collection-visual-debugger .vc_visualization-item-container {
40
- position: absolute;
41
- width: 500px;
42
- background: rgba(255, 255, 255, .15);
43
- }
44
-
45
- .vertical-collection-visual-debugger .vc_visualization-virtual-component {
46
- box-sizing: border-box;
47
- background: rgba(230, 100, 230, 0.6);
48
- border: 1px dotted #bbb;
49
- border-top: 0px;
50
- color: #fff;
51
- text-align: center;
52
- font-size: 2.5em;
53
- width: 250px;
54
- }
55
-
56
- .vertical-collection-visual-debugger .vc_visualization-virtual-component:first-of-type {
57
- border-top: 1px dotted #bbb;
58
- }
59
-
60
- .vertical-collection-visual-debugger .vc_visualization-virtual-component.culled {
61
- background: transparent;
62
- }
File without changes