Skip to content

Commit

Permalink
issue-156 scrollToItem demo description
Browse files Browse the repository at this point in the history
  • Loading branch information
dhilt committed Apr 24, 2020
1 parent 851ee58 commit f570185
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions demo/app/samples/experimental.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export class ExperimentalComponent {
minIndex?: number;
maxIndex?: number;
updater?: (item: ItemAdapter) => any;
scrollToItem?: (item: ItemAdapter) => boolean;
scrollToItemOpt?: boolean | ScrollIntoViewOptions;
}`;

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<app-demo [datasource]="datasource" [context]="demoContext" [sources]="sources">

<div actions>
<div class="comment">Available since v1.4.5, undocumented</div>
<div class="comment">Available since v1.6.2, undocumented</div>
<button (click)="doScrollTo()">Scroll to</button> item #
<input [(ngModel)]="index" size="2">
<br>
Expand All @@ -10,7 +10,18 @@

<div description>
<p>
<em>Adapter.fix</em> method could be invoked with <em>scrollToItem</em> option
What if we want to scroll to a specific item in the viewport?
This can be done via <em>scrollToItem</em> option of the <em>Adapter.fix</em> method.
This option specifies an item predicate function, and the first item in the Buffer,
that satisfies this predicate, will be the item to which the viewport will scroll.
</p>
<p>
Scrolling is performed via <em>element.scrollIntoView()</em> native DOM Element interface's method.
According to its specification, it accepts 1 optional argument which can be a Boolean parameter or
special Object parameter (details can be found on
<a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView">MDN</a>).
To provide this option, the <em>Adapter.fix</em> method handles another property of its argument object:
<em>scrollToItemOpt</em>. The demo shows how to use it.
</p>
</div>
</app-demo>
1 change: 0 additions & 1 deletion src/component/interfaces/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export interface AdapterFixOptions {
updater?: ItemsLooper;
scrollToItem?: ItemsPredicate;
scrollToItemOpt?: boolean | ScrollIntoViewOptions;
safe?: boolean;
}

export interface IAdapter {
Expand Down

0 comments on commit f570185

Please sign in to comment.