Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow 5 #67

Merged
merged 171 commits into from
Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
171 commits
Select commit Hold shift + click to select a range
88db8f0
min/max indexes and average size
dhilt Jun 24, 2018
7c67795
cache items after render, keep size
dhilt Jun 24, 2018
176d258
min/max indexes on Buffer
dhilt Jun 24, 2018
1366a0e
do not build
dhilt Jun 24, 2018
3754e59
do not build
dhilt Jun 24, 2018
0730edd
Merge branch 'master' of github.com:dhilt/ngx-ui-scroll into workflow-5
dhilt Jun 24, 2018
39aad65
min/maxIndex, itemSize settings
dhilt Jul 15, 2018
593e35e
prepare scroller hierarchy to non-directional fetching
dhilt Jul 15, 2018
8a349f3
prepare processes to non-directional fetching
dhilt Jul 15, 2018
5d778e5
initial load does work
dhilt Jul 18, 2018
a688bd9
Merge branch 'first-visible' into workflow-5
dhilt Jul 18, 2018
1a34d06
switch preFetch from items indexes to items positions
dhilt Jul 23, 2018
a9164bb
preFetch cleanup
dhilt Jul 23, 2018
aef050d
Merge branch 'master' into workflow-5
dhilt Jul 25, 2018
44bf160
workflow-5: clip before fetch
dhilt Jul 27, 2018
6228911
unidirectional clip
dhilt Jul 28, 2018
70915a2
forward scroll does work
dhilt Jul 29, 2018
70cb0f6
fix forward padding size when the viewport is not filled enough
dhilt Jul 29, 2018
2d370ff
geometry fixes
dhilt Aug 2, 2018
7a02d29
backward scroll does work (fold case)
dhilt Aug 6, 2018
53ac5d7
eof/bof refactoring
dhilt Aug 6, 2018
3b97330
explicit bwd items
dhilt Aug 8, 2018
b8dc683
Merge branch 'master' into workflow-5
dhilt Aug 8, 2018
1de86c1
positive scroll up does work
dhilt Aug 9, 2018
f896b90
negative size approach
dhilt Aug 10, 2018
1de0b6e
reload index fix
dhilt Aug 10, 2018
b97fbc1
protect buffer reload
dhilt Aug 10, 2018
9f5058a
test demo updates (delay input)
dhilt Aug 11, 2018
98c5a37
clip padding
dhilt Aug 11, 2018
9f36315
inertialScrollDelay and logTime dev settings
dhilt Aug 12, 2018
8129f86
native event handling
dhilt Aug 17, 2018
f7b8dc3
inertia settings
dhilt Aug 19, 2018
1fc3ecb
Adapter.showLog()
dhilt Aug 19, 2018
e529064
logger
dhilt Aug 19, 2018
cf8852c
negative size calculation during post-render process
dhilt Aug 20, 2018
f70ee0c
workflow direction cleanup
dhilt Aug 21, 2018
ecf0982
reduce unnecessary workflow calls on synthetic scroll
dhilt Aug 21, 2018
02d6a7e
logger non-debug optimization
dhilt Aug 22, 2018
526a398
preFetch set first and last indexes refactoring
dhilt Aug 23, 2018
5a9c6a1
shift fetch index in bof case
dhilt Aug 23, 2018
3aef649
workflow-5, clip after fetch
dhilt Aug 24, 2018
dac2d8b
initial poor fetch -> start-indexed bof
dhilt Aug 24, 2018
b3cbd1c
scroll direction
dhilt Aug 26, 2018
0e45de7
fetch model keeps info about what items should be in the buffer
dhilt Aug 28, 2018
22ebdb9
clip is a part of post-render (wf-5 draft)
dhilt Aug 28, 2018
d423a13
unhide items during Render process
dhilt Aug 28, 2018
4cbc01e
extract Clip process
dhilt Aug 28, 2018
77e9bf1
Adjust process
dhilt Aug 28, 2018
ffbcf53
Workflow 5 draft cleanup
dhilt Aug 28, 2018
8dc16e3
padding adjustments during clip
dhilt Aug 28, 2018
5134ded
clarify scroll direction
dhilt Aug 29, 2018
d6c2f42
entire window offset
dhilt Aug 29, 2018
b7970e3
move synthetic scroll data to State
dhilt Aug 30, 2018
7c3644e
ProcessStatus
dhilt Aug 30, 2018
2939542
Tests: add static config to initial load spec
Sep 1, 2018
bf17526
test runner types fix
dhilt Sep 4, 2018
b3402ef
min/max indexes
dhilt Sep 5, 2018
a7fdb90
workflow-5 unused code cleanup
dhilt Sep 5, 2018
bbae2c7
simplify initial-load spec
dhilt Sep 5, 2018
df6a282
automated "Fixed average item size" sub-spec
dhilt Sep 5, 2018
2e6b84f
Fixed average item size sub-spec, big bufferSize case
dhilt Sep 5, 2018
712b324
finalize initial-load spec
dhilt Sep 6, 2018
e857a8b
include load and common specs
dhilt Sep 8, 2018
68ef70b
viewport/paddings reset fix
dhilt Sep 8, 2018
aabba94
viewport/paddings reset fix (2)
dhilt Sep 8, 2018
5d88c37
reload index fix
dhilt Sep 8, 2018
cb3e542
Tests: add static config to basic scroll spec
Sep 9, 2018
fdad68f
correct tests for Chrome 68.0.3440
dyuvzhenko Sep 9, 2018
8e5ac45
Tests: add another static config to basic scroll spec
dyuvzhenko Sep 9, 2018
bea3f18
fix negative size on scroll/reload
dhilt Sep 10, 2018
e635baa
min/max indexes spec, common cases
dhilt Sep 11, 2018
b132081
Update packages to eliminate cryptiles security issue
dhilt Sep 12, 2018
9a25672
tests and fix for startIndex is around minIndex case
dhilt Sep 12, 2018
f38130d
tests and fix for startIndex around maxIndex cases
dhilt Sep 13, 2018
d4851fc
Adapte.setMinIndex method
dhilt Sep 13, 2018
087786d
Merge branch 'master' into workflow-5
dhilt Sep 15, 2018
e3fbea2
replace Cache Array with Map
dhilt Sep 16, 2018
3a2f49b
setting direction on 2+ fetch per workflow cycle (init/reload cases)
dhilt Sep 16, 2018
882976d
Workflow v5.5
dhilt Sep 18, 2018
6993680
extract ScrollState and SyntheticScroll classes
dhilt Sep 18, 2018
44ce583
WF 5.5 - abandon scroll direction, use fetch direction instead
dhilt Sep 19, 2018
6459d4d
Process payload specification
dhilt Sep 19, 2018
c282f3b
wf cycle, inner loop, v1.0.0-beta
dhilt Sep 20, 2018
637b1b6
skip clip on init + fix half of initial-load spec
dhilt Sep 20, 2018
90a5413
fixed 3/4 of initial load spec
dhilt Sep 21, 2018
cde6273
initial load spec does work
dhilt Sep 21, 2018
12ee853
min-max indexes spec fix
dhilt Sep 21, 2018
ef61d9d
ItemsCounter tests refactoring
dhilt Sep 22, 2018
2b58b1f
first 5 tests of scroll-basic spec
dhilt Sep 22, 2018
eaa7a78
basic scroll spec: single max fwd/bwd scroll event cases (first 10 te…
dhilt Sep 22, 2018
b7d04cc
repair 50% of basic scroll spec
dhilt Sep 23, 2018
1cc540c
scroll basic spec prev state refactoring
dhilt Sep 24, 2018
d243211
fetch log + scroll basic 3/4 spec
dhilt Sep 26, 2018
471ca12
scroll basic spec is done
dhilt Sep 26, 2018
7477487
no min/max index sub-specs
dhilt Sep 29, 2018
3bbc195
average item size recalculation
dhilt Sep 30, 2018
7464173
itemSize has no default
dhilt Oct 1, 2018
123fa7b
Travis returns
dhilt Oct 2, 2018
a941fe1
no itemSize sub-spec
dhilt Oct 2, 2018
1663735
no itemSize min/maxIndexes sub-spec
dhilt Oct 2, 2018
c1e9b0b
delay settings
dhilt Oct 4, 2018
54b48a7
entire window scrollable (min/max indexes are set)
dhilt Oct 7, 2018
0a1eb88
safari window scrollable element fix
dhilt Oct 9, 2018
637f2f0
entire window scrollable cleanup
dhilt Oct 9, 2018
dcdbe6d
fix wf cycle break if there were 2 packs and first was empty
dhilt Oct 9, 2018
597eebd
include 8 eof/bof tests
dhilt Oct 9, 2018
4aaff31
provide dynamic sizes into test component
dhilt Oct 10, 2018
966c748
extract testItemsCounter
dhilt Oct 10, 2018
2fe3e4b
dynamic-size spec, first 2 tests
dhilt Oct 10, 2018
84dee96
scrollable size can't be less than viewport size
dhilt Oct 11, 2018
f3ca3fc
keep original float value of average item size
dhilt Oct 11, 2018
1a4e1cd
skip synthetic scroll in window mode
dhilt Oct 11, 2018
a5ccfdd
dynamic size spec refactoring, 4 generic tests
dhilt Oct 11, 2018
893bbfb
2 more tests for dynamic spec
dhilt Oct 11, 2018
8bc84b1
adapter setScrollPosition
dhilt Oct 12, 2018
928c1fd
dynamic-size scroll sub-spec
dhilt Oct 12, 2018
daa3b49
fix horizontal scroll adjustment (rounding) + cleanup
dhilt Oct 12, 2018
c1a082c
basic and bufferSize demos
dhilt Oct 13, 2018
fc30bbe
common demo description and styling
dhilt Oct 13, 2018
a46cf60
padding demo
dhilt Oct 13, 2018
4114dfa
itemSize demo
dhilt Oct 13, 2018
89ebeb5
startIndex demo
dhilt Oct 13, 2018
bf63eaf
demos: scrollable size counter
dhilt Oct 13, 2018
c10d23e
min-max indexes demo
dhilt Oct 14, 2018
6f91ef9
infinite mode fix
dhilt Oct 14, 2018
0de6b9f
horizontal demo fix
dhilt Oct 14, 2018
edb7199
preinstall and postinstall scripts
dhilt Oct 14, 2018
95cc611
preinstall @angular/cli
dhilt Oct 14, 2018
c27741a
move postinstall build to dist
dhilt Oct 15, 2018
4c4f160
express static server
dhilt Oct 15, 2018
fe79238
Procfile
dhilt Oct 15, 2018
3efa08a
install server dependencies (preinstall)
dhilt Oct 15, 2018
a6b7a91
Merge pull request #70 from dhilt/heroku
dhilt Oct 15, 2018
d6f9049
reload demos: common description and reload demo
dhilt Oct 20, 2018
8a02f3f
isLoading, loopPending and cyclePending
dhilt Oct 21, 2018
995d8f3
isLoading demo
dhilt Oct 21, 2018
6ccb106
isLoading advanced demo
dhilt Oct 21, 2018
e8ac57b
buffer items count demo
dhilt Oct 21, 2018
1543bb6
first/last visible items on-demand calculation
dhilt Oct 22, 2018
3544fc8
first and last visible items adapter demo
dhilt Oct 23, 2018
1a58c4a
basic documentation improvements
dhilt Oct 24, 2018
c3c3b52
settings table doc
dhilt Oct 24, 2018
7206076
Adapter basic documentation
dhilt Oct 24, 2018
03f7125
devSettings readme
dhilt Oct 24, 2018
be0d8e5
maxSynthScrollDelay
dhilt Oct 26, 2018
3ec7092
debounce first scroll
dhilt Oct 26, 2018
c808e82
Datasource demo page
dhilt Oct 27, 2018
44a61cc
datasource demo sub-pages infrastructure
dhilt Oct 27, 2018
4638abb
datasource get method signatures demo
dhilt Oct 27, 2018
84f2453
limited datasources demos
dhilt Oct 27, 2018
f861718
inverted datasource demo
dhilt Oct 28, 2018
23259b9
pages datasource demo
dhilt Oct 28, 2018
4e65c9d
Demo: styling fixes for better readability
Oct 30, 2018
6906f34
Demo: header styling fixes
Oct 30, 2018
f15724c
Demo: log styling fix (allow scrolling if needed)
Oct 30, 2018
02efbc7
Demo: styling fix: only datasource log should have scroll
Oct 30, 2018
8cccf1c
Demo: improved typography
Oct 30, 2018
a41e306
Demo: highlight currently active menu item
Oct 31, 2018
fb8e397
demo app home page
dhilt Oct 31, 2018
f34f2b5
itemAdapterEmpty
dhilt Oct 31, 2018
af2e443
Demo: input and button styling
Oct 31, 2018
8d7bcb9
Demo: log styling fix (always keep top/bottom padding)
Oct 31, 2018
46f7362
datasource demos upd.
dhilt Nov 1, 2018
a61597b
example list for Home component
dyuvzhenko Nov 1, 2018
633cee5
Demo: align examples into 1 column on small screens
Nov 1, 2018
0469ba6
move example list down
dhilt Nov 2, 2018
9396f3e
odd/even local template variables
dhilt Nov 2, 2018
1a460a0
demo sources refactoring
dhilt Nov 5, 2018
9b0b8a7
remote datasource demo
dhilt Nov 5, 2018
97b6e6e
fix demo app build
dhilt Nov 5, 2018
227997e
Merge pull request #72 from dhilt/workflow-5-styling
dhilt Nov 5, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: node server/index.js
114 changes: 97 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,29 @@ Unlimited bidirectional scrolling over limited viewport. A directive for [Angula
- [Features](#features)
- [Getting](#getting)
- [Usage](#usage)
- [Developing](#developing)
- [Settings](#settings)
- [Adapter API](#adapter-api)
- [Development](#development)

### Motivation

The common way to present a list of data elements of undefined length is to start with a small portion - just enough to fill the space on the page. Additional blocks are added to the list as the user scrolls to the edge of the list. The problem with this approach is that even though blocks at the edge of the list become invisible as they scroll out of the view, they are still a part of the page and still consume resources.
Scrolling large date sets may cause performance issues. Many DOM elements, many data-bindings, many event listeners... The common way to improve this case is to render only a small portion of the data set visible to the user. Other data set elements that are not visible to the user are virtualized with upward and downward empty padding elements which should give us a consistent viewport with consistent scrollbar parameters.

The \*uiScroll directive dynamically destroys elements as they become invisible and recreating them if they become visible again. This is structural directive that works like \*ngFor and instantiates a template once per item from a collection. The \*uiScroll directive is asking the datasource for data to build and render elements until it has enough elements to fill out the viewport. It will start retrieving new data for new elements again if the user scrolls to the edge of visible element list.
The \*uiScroll is structural directive that works like \*ngFor and renders a templated element once per item from a collection. By requesting the external Datasource (the implementation of which is a developer responsibility) the \*uiScroll directive fetches necessary portion of the data set and renders corresponded elements until the visible part of the viewport is filled out. It starts to retrieve new data to render new elements again if the user scrolls to the edge of visible element list. It dynamically destroys elements as they become invisible and recreates them if they become visible again.
<p align="center">
<img src="https://raw.githubusercontent.com/dhilt/ngx-ui-scroll/master/demo/assets/ngx-ui-scroll-demo.gif">
</p>

### Features

- unlimited virtual scroll
- virtualization settings (you can specify when and how many items need to be requested/rendered by the uiScroll), [demos](https://dhilt.github.io/ngx-ui-scroll/#/#buffer-size-setting)
- infinite mode (items rendered once are never removed), [demo](https://dhilt.github.io/ngx-ui-scroll/#/#infinite-mode)
- horizontal mode, [demo](https://dhilt.github.io/ngx-ui-scroll/#/#horizontal-mode)
- different item heights, [demo](https://dhilt.github.io/ngx-ui-scroll/#/#different-item-heights)
- entire window scrollable, [demo](https://dhilt.github.io/ngx-ui-scroll/#/#window-viewport-setting)
- special Adapter API object to manipulate and assess the scroller, [demos](https://dhilt.github.io/ngx-ui-scroll/#/adapter)
- unlimited bidirectional virtual scroll
- lots of virtualization settings
- super easy templating
- infinite mode, [demo](https://dhilt.github.io/ngx-ui-scroll/#settings#infinite-mode)
- horizontal mode, [demo](https://dhilt.github.io/ngx-ui-scroll/#settings#horizontal-mode)
- entire window scrollable, [demo](https://dhilt.github.io/ngx-ui-scroll/#settings#window-viewport)
- items with non-constant heights, [demo](https://dhilt.github.io/ngx-ui-scroll/#settings#different-item-heights)
- API Adapter object to manipulate and assess the scroller, [demos](https://dhilt.github.io/ngx-ui-scroll/#/adapter)

### Getting

Expand Down Expand Up @@ -78,14 +81,13 @@ where the viewport is a scrollable area of finite height.
}
```

\*uiScroll acts like \*ngFor, but the datasource is an object of special type (IDatasource) that can be imported to the host component from UiScrollModule. It implements method _get_ to be used by the \*uiScroll directive to access the data by _index_ and _count_ parameters.
\*uiScroll acts like \*ngFor, but the datasource is an object of special type (IDatasource). It implements method _get_ to be used by the \*uiScroll directive to access the data by _index_ and _count_ parameters.

```javascript
import { IDatasource } from 'ngx-ui-scroll';

export class AppComponent {

public datasource: IDatasource = {
datasource: IDatasource = {
get: (index, count, success) => {
const data = [];
for (let i = index; i <= index + count - 1; i++) {
Expand All @@ -97,18 +99,78 @@ export class AppComponent {
}
```

_Datasource.get_ must provide an array of _count_ data-items started from _index_ position. _Datasource.get_ has 3 signatures: callback based, Promise based and Observable based. So, if you want some remote API to be a source of your data, basically it may look like
_Datasource.get_ must provide an array of _count_ data-items started from _index_ position. _Datasource.get_ has 3 signatures: callback based, Promise based and Observable based. So, if we want some remote API to be a source of our data, basically it may look like

```javascript
public datasource: IDatasource = {
datasource: IDatasource = {
get: (index, count) =>
this.http.get(`${myApiUrl}?index=${index}&count=${count}`)
};
```

More details could be found on the [DEMO page](https://dhilt.github.io/ngx-ui-scroll/).
More details could be found on the [Datasource demo page](https://dhilt.github.io/ngx-ui-scroll/#/datasource).

### Settings

### Developing
Datasource implementation along with _get_ method property may include _settings_ object property:

```javascript
datasource: IDatasource = {
get: ...,
settings: {
minIndex: 0,
startIndex: 0,
...
}
};
```

Settings are being applied during the uiScroll initialization and have an impact on how the uiScroll behaves. Below is the list of available settings with descriptions, defaults, types and demos.

|Name|Type|Default|Description|
|:--|:----:|:----------:|:----------|
|[bufferSize](https://dhilt.github.io/ngx-ui-scroll/#settings#buffer-size)|number,<br>integer|5| Fixes minimal size of the pack of the datasource items to be requested per single _Datasource.get_ call. Can't be less than 1. |
|[padding](https://dhilt.github.io/ngx-ui-scroll/#settings#padding)|number,<br>float|0.5| Determines viewport outlets relative to the viewport's size that need to be filled. For example, 0.5 means that we'll have as many items at a moment as needed to fill out 100% of the visible part of the viewport, + 50% of the viewport size in backward direction and + 50% in forward direction. The value can't be less than 0.01. |
|[startIndex](https://dhilt.github.io/ngx-ui-scroll/#settings#start-index)|number,<br>integer|1| Specifies item index to be requested/rendered first. Can be any, but real datasource boundaries should be taken into account. |
|[minIndex](https://dhilt.github.io/ngx-ui-scroll/#settings#min-max-indexess)|number,<br>integer|-Infinity| Fixes absolute minimal index of the data set. The datasource left boundary. |
|[maxIndex](https://dhilt.github.io/ngx-ui-scroll/#settings#min-max-indexess)|number,<br>integer|+Infinity| Fixes absolute maximal index of the data set. The datasource right boundary. |
|[infinite](https://dhilt.github.io/ngx-ui-scroll/#settings#infinite-mode)|boolean|false| Allows to run "infinite" mode, when items rendered once are never removed. |
|[horizontal](https://dhilt.github.io/ngx-ui-scroll/#settings#horizontal-mode)|boolean|false| Allows to run "horizontal" mode, when the viewport's orientation is horizontal. |
|[windowViewport](https://dhilt.github.io/ngx-ui-scroll/#settings#window-viewport)|boolean|false| Allows to run "entire window scrollabe" mode, when the entire window becomes the scrollable viewport. |

### Adapter API

The uiScroll has API to assess its parameters and provide some manipulations run-time. This API is available via special Adapter object. The datasource needs to be instantiated via operator "new" fot the Adapter object to be added to it:

```javascript
import { Datasource } from 'ngx-ui-scroll';
...
datasource = new Datasource({
get: ... ,
settings: { ... }
});
```

Then `this.datasource.adapter.version`, `this.datasource.adapter.reload()` and other Adapter expressions become legal. Below is the list of read-only properties of the Adapter API.

|Name|Type|Description|
|:--|:----|:----------|
|version|string|Current version of ngx-ui-scroll library|
|[isLoading](https://dhilt.github.io/ngx-ui-scroll/#/adapter#is-loading)|boolean|Indicates whether the uiScroll is working ot not. |
|[isLoading$](https://dhilt.github.io/ngx-ui-scroll/#/adapter#is-loading)|BehaviorSubject<br>&lt;boolean&gt;|An Observable version of "isLoading" property. |
|[itemsCount](https://dhilt.github.io/ngx-ui-scroll/#/adapter#items-count)|number|A number of items that are rendered in the viewport at a moment.|
|[firstVisible](https://dhilt.github.io/ngx-ui-scroll/#/adapter#first-last-visible-items)|ItemAdapter {<br>&nbsp;&nbsp;$index?:&nbsp;number;<br>&nbsp;&nbsp;data?:&nbsp;any;<br>&nbsp;&nbsp;element?:&nbsp;HTMLElement;<br>}|Object of ItemAdapter type containing information about first visible item, where "$index" corresponds to the datasource item index value, "data" is exactly the item's content, "element" is a link to DOM element which is relevant to the item. |
|[firstVisible$](https://dhilt.github.io/ngx-ui-scroll/#/adapter#first-last-visible-items)|BehaviorSubject<br>&lt;ItemAdapter&gt;|An observable version of "firstVisible" property. |
|[lastVisible](https://dhilt.github.io/ngx-ui-scroll/#/adapter#first-last-visible-items)|ItemAdapter|Object of ItemAdapter type containing information about last visible item. |
|[lastVisible$](https://dhilt.github.io/ngx-ui-scroll/#/adapter#first-last-visible-items)|BehaviorSubject<br>&lt;ItemAdapter&gt;|An observable version of "lastVisible" property. |

Below is the list of invocable methods of the Adapter API.

|Name|Parameters|Description|
|:--|:----|:----------|
|[reload](https://dhilt.github.io/ngx-ui-scroll/#/adapter#reload)|(startIndex?:&nbsp;number)|Resets the items buffer, resets the viewport params and starts fetching items from "startIndex" (if set). |

### Development

There are some npm scripts available from package.json:

Expand All @@ -117,6 +179,24 @@ There are some npm scripts available from package.json:
- `npm run build` to build the ngx-ui-scroll module into the ./dist folder
- `npm run install-package` to build tar-gzipped version of package and install it locally into ./node_modules

Along with settings object the datasource implementation may include also devSettings object:

```javascript
import { Datasource } from 'ngx-ui-scroll';
...
datasource = new Datasource({
get: ... ,
settings: { ... },
devSettings: {
debug: true,
immediateLog: true,
...
}
});
```

We are not going to discuss development settings here, information about it can be obtained directly from the [source code](https://github.com/dhilt/ngx-ui-scroll/blob/master/src/component/classes/settings.ts), but the uiScroll has "debug" mode with powerful logging which can be enabled via `devSettings.debug = true`. Also, with `devSettings.immediateLog = false` the console logging will be postponed until the undocumented Adapter method `showLog` is called (`datasource.adapter.showLog()`). This case could be important from the performance view: there might be too many logs and pushing them to the console output immediately could slow down the App.

The work has just begun. We have great plans and any participation is welcome! So, feel free to submit new issues and open Pull Requests.

__________
Expand Down
10 changes: 7 additions & 3 deletions demo/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { CommonComponent } from './samples/common.component';
import { HomeComponent } from './samples/home.component';
import { SettingsComponent } from './samples/settings.component';
import { AdapterComponent } from './samples/adapter.component';
import { DatasourceComponent } from './samples/datasource.component';
import { WindowComponent } from './samples/window.component';
import { TestComponent } from './samples/test.component';

const routes: Routes = [
{ path: '', component: CommonComponent },
{ path: '', component: HomeComponent },
{ path: 'settings', component: SettingsComponent },
{ path: 'adapter', component: AdapterComponent },
{ path: 'datasource', component: DatasourceComponent },
{ path: 'window', component: WindowComponent },
{ path: 'test', component: TestComponent },
{ path: '**', redirectTo: '', pathMatch: 'full' },
{ path: '**', redirectTo: '', pathMatch: 'full' }
];

@NgModule({
Expand Down
2 changes: 0 additions & 2 deletions demo/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

<div class="container mb-5">

<h1>Angular UI Scroll Demo</h1>

<router-outlet></router-outlet>

</div>
Expand Down
3 changes: 3 additions & 0 deletions demo/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export class AppComponent implements AfterViewInit, OnDestroy {
this.hasLayout = !(event.url === '/window' || event.url === '/test');
})
);
if ('scrollRestoration' in history) {
history.scrollRestoration = 'manual';
}
}

ngAfterViewInit() {
Expand Down
37 changes: 35 additions & 2 deletions demo/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { TabsModule } from 'ngx-bootstrap';

import { UiScrollModule } from '../../public_api'; // from 'ngx-ui-scroll';
Expand All @@ -9,19 +10,33 @@ import { AppComponent } from './app.component';
import { NavComponent } from './shared/nav.component';
import { DemoComponent } from './shared/demo.component';

import { CommonComponent } from './samples/common.component';
import { HomeComponent } from './samples/home.component';
import { SettingsComponent } from './samples/settings.component';
import { AdapterComponent } from './samples/adapter.component';
import { DatasourceComponent } from './samples/datasource.component';

import { DemoBasicComponent } from './samples/common/basic.component';
import { DemoBufferSizeComponent } from './samples/common/buffer-size.component';
import { DemoPaddingComponent } from './samples/common/padding.component';
import { DemoItemSizeComponent } from './samples/common/item-size.component';
import { DemoStartIndexComponent } from './samples/common/start-index.component';
import { DemoMinMaxIndexesComponent } from './samples/common/min-max-indexes.component';
import { DemoInfiniteComponent } from './samples/common/infinite.component';
import { DemoHorizontalComponent } from './samples/common/horizontal.component';
import { DemoDifferentHeightsComponent } from './samples/common/different-heights.component';
import { DemoWindowViewportComponent } from './samples/common/window-viewport.component';
import { DemoReloadComponent } from './samples/adapter/reload.component';
import { DemoIsLoadingComponent } from './samples/adapter/is-loading.component';
import { DemoItemsCountComponent } from './samples/adapter/items-count.component';
import { DemoFirstLastVisibleItemsComponent } from './samples/adapter/first-last-visible-items.component';
import { DemoIsLoadingExtendedComponent } from './samples/adapter/is-loading-extended.component';
import { DemoDatasourceSignaturesComponent } from './samples/datasource/datasource-signatures.component';
import { DemoBidirectionalUnlimitedDatasourceComponent } from './samples/datasource/bidirectional-unlimited-datasource.component';
import { DemoLimitedDatasourceComponent } from './samples/datasource/limited-datasource.component';
import { DemoPositiveLimitedDatasourceComponent } from './samples/datasource/positive-limited-datasource.component';
import { RemoteDataService, DemoRemoteDatasourceComponent } from './samples/datasource/remote-datasource.component';
import { DemoInvertedDatasourceComponent } from './samples/datasource/inverted-datasource.component';
import { DemoPagesDatasourceComponent } from './samples/datasource/pages-datasource.component';
import { WindowComponent } from './samples/window.component';
import { TestComponent, TestInnerComponent } from './samples/test.component';

Expand All @@ -32,29 +47,47 @@ import { AppRoutingModule } from './app-routing.module';
AppComponent,
NavComponent,
DemoComponent,
CommonComponent,
HomeComponent,
SettingsComponent,
AdapterComponent,
DatasourceComponent,
DemoBasicComponent,
DemoBufferSizeComponent,
DemoPaddingComponent,
DemoItemSizeComponent,
DemoStartIndexComponent,
DemoMinMaxIndexesComponent,
DemoInfiniteComponent,
DemoHorizontalComponent,
DemoDifferentHeightsComponent,
DemoWindowViewportComponent,
DemoReloadComponent,
DemoIsLoadingComponent,
DemoItemsCountComponent,
DemoFirstLastVisibleItemsComponent,
DemoIsLoadingExtendedComponent,
DemoDatasourceSignaturesComponent,
DemoBidirectionalUnlimitedDatasourceComponent,
DemoLimitedDatasourceComponent,
DemoPositiveLimitedDatasourceComponent,
DemoRemoteDatasourceComponent,
DemoInvertedDatasourceComponent,
DemoPagesDatasourceComponent,
WindowComponent,
TestComponent,
TestInnerComponent
],
imports: [
BrowserModule,
FormsModule,
HttpClientModule,
TabsModule.forRoot(),
UiScrollModule,
AppRoutingModule
],
providers: [
RemoteDataService
],
bootstrap: [AppComponent]
})
export class AppModule {
Expand Down
27 changes: 27 additions & 0 deletions demo/app/samples/adapter.component.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,29 @@
<h1>Angular UI Scroll Adapter Demos</h1>

<p>
<em>Adapter</em> is&nbsp;a&nbsp;special object to&nbsp;assess and manipulate the <em>uiScroll</em>.
The API it&nbsp;provides is&nbsp;being discussed on&nbsp;this page.
Currently the only way to&nbsp;receive the <em>Adapter</em> is&nbsp;to&nbsp;instantiate
the <em>Datasource</em> via operator <em>new</em>:
</p>

<pre>{{datasourceSample}}</pre>

<p>
The constructor argument is&nbsp;an&nbsp;object of&nbsp;<em>IDatasource</em> type which
must include <em>get</em> method property and
may include <em>settings</em> object property.
The <em>uiScroll</em> augments the result <em>Datasource</em> object
with the <em>Adapter</em> object property during instantiating.
So, after the <em>Datasource</em> object had been instantiated, we&nbsp;may access
<em>this.datasource.adapter</em> property object with its API methods and properties.
<em>Datasource</em> definition could be&nbsp;imported from the <em>UiScrollModule</em>:
</p>

<pre>{{importSample}}</pre>

<app-demo-reload></app-demo-reload>
<app-demo-is-loading></app-demo-is-loading>
<app-demo-items-count></app-demo-items-count>
<app-demo-first-last-visible-items></app-demo-first-last-visible-items>
<app-demo-is-loading-extended></app-demo-is-loading-extended>
8 changes: 8 additions & 0 deletions demo/app/samples/adapter.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@ export class AdapterComponent {
constructor() {
}


importSample = ` import { Datasource } from 'ngx-ui-scroll';`;

datasourceSample = ` datasource = new Datasource({
get: ... ,
settings: { ... }
});`;

}
Loading