Skip to content

feat(virtual-scroll): fixed size virtual scroll #9316

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

Merged
merged 5 commits into from
Feb 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 5 additions & 4 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Angular Material components
/src/lib/* @jelbourn
/src/lib/autocomplete/** @kara @crisbeto
/src/lib/badge/** @amcdnl
/src/lib/bottom-sheet/** @jelbourn @crisbeto
/src/lib/button-toggle/** @tinayuangao
/src/lib/button/** @tinayuangao
Expand Down Expand Up @@ -32,7 +33,6 @@
/src/lib/tabs/** @andrewseguin
/src/lib/toolbar/** @devversion
/src/lib/tooltip/** @andrewseguin
/src/lib/badge/** @amcdnl

# Angular Material core
/src/lib/core/* @jelbourn
Expand All @@ -41,10 +41,10 @@
/src/lib/core/datetime/** @mmalerba
/src/lib/core/error/** @crisbeto @mmalerba
/src/lib/core/gestures/** @jelbourn
/src/lib/core/label/** @kara @mmalerba
/src/lib/core/line/** @jelbourn
/src/lib/core/option/** @kara @crisbeto
/src/lib/core/placeholder/** @kara @mmalerba
/src/lib/core/label/** @kara @mmalerba
/src/lib/core/ripple/** @devversion
/src/lib/core/selection/** @tinayuangao @jelbourn
/src/lib/core/selection/pseudo*/** @crisbeto @jelbourn
Expand Down Expand Up @@ -90,8 +90,9 @@
/src/demo-app/* @jelbourn
/src/demo-app/a11y/** @tinayuangao
/src/demo-app/autocomplete/** @kara @crisbeto
/src/demo-app/bottom-sheet/** @jelbourn @crisbeto
/src/demo-app/badge/** @amcdnl
/src/demo-app/baseline/** @mmalerba
/src/demo-app/bottom-sheet/** @jelbourn @crisbeto
/src/demo-app/button-toggle/** @tinayuangao
/src/demo-app/button/** @tinayuangao
/src/demo-app/card/** @jelbourn
Expand Down Expand Up @@ -130,7 +131,7 @@
/src/demo-app/toolbar/** @devversion
/src/demo-app/tooltip/** @andrewseguin
/src/demo-app/typography/** @crisbeto
/src/demo-app/badge/** @amcdnl
/src/demo-app/virtual-scroll/** @mmalerba

# E2E app
/e2e/* @jelbourn
Expand Down
7 changes: 6 additions & 1 deletion src/cdk/collections/collection-viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

import {Observable} from 'rxjs/Observable';


/** Represents a range of numbers with a specified start and end. */
export type Range = {start: number, end: number};


/**
* Interface for any component that provides a view of some data collection and wants to provide
* information regarding the view and any changes made.
Expand All @@ -17,5 +22,5 @@ export interface CollectionViewer {
* A stream that emits whenever the `CollectionViewer` starts looking at a new portion of the
* data. The `start` index is inclusive, while the `end` is exclusive.
*/
viewChange: Observable<{start: number, end: number}>;
viewChange: Observable<Range>;
}
1 change: 1 addition & 0 deletions src/cdk/collections/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import {Observable} from 'rxjs/Observable';
import {CollectionViewer} from './collection-viewer';


export abstract class DataSource<T> {
/**
* Connects a collection viewer (such as a data-table) to this data source. Note that
Expand Down
1 change: 1 addition & 0 deletions src/cdk/collections/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
export * from './collection-viewer';
export * from './data-source';
export * from './selection';
export * from './static-array-data-source';
export {
UniqueSelectionDispatcher,
UniqueSelectionDispatcherListener,
Expand Down
23 changes: 23 additions & 0 deletions src/cdk/collections/static-array-data-source.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

import {Observable} from 'rxjs/Observable';
import {of as observableOf} from 'rxjs/observable/of';
import {DataSource} from './data-source';


/** DataSource wrapper for a native array. */
export class StaticArrayDataSource<T> implements DataSource<T> {
constructor(private _data: T[]) {}

connect(): Observable<T[]> {
return observableOf(this._data);
}

disconnect() {}
}
24 changes: 21 additions & 3 deletions src/cdk/scrolling/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package(default_visibility=["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_binary")


ng_module(
name = "scrolling",
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
module_name = "@angular/cdk/scrolling",
assets = [
":virtual_scroll_viewport_css",
],
deps = [
"//src/cdk/collections",
"//src/cdk/platform",
"@rxjs",
],
Expand All @@ -28,9 +33,7 @@ ts_library(

ts_web_test(
name = "unit_tests",
bootstrap = [
"//:web_test_bootstrap_scripts",
],
bootstrap = ["//:web_test_bootstrap_scripts"],

# Do not sort
deps = [
Expand All @@ -41,3 +44,18 @@ ts_web_test(
":scrolling_test_sources",
],
)

sass_binary(
name = "virtual_scroll_viewport_scss",
src = "virtual-scroll-viewport.scss",
)

# TODO(jelbourn): remove this when sass_binary supports specifying an output filename and dir.
# Copy the output of the sass_binary such that the filename and path match what we expect.
genrule(
name = "virtual_scroll_viewport_css",
srcs = [":virtual_scroll_viewport_scss"],
outs = ["virtual-scroll-viewport.css"],
cmd = "cat $(locations :virtual_scroll_viewport_scss) > $@",
)

4 changes: 3 additions & 1 deletion src/cdk/scrolling/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* found in the LICENSE file at https://angular.io/license
*/

export * from './virtual-for-of';
export * from './scroll-dispatcher';
export * from './scrollable';
export * from './viewport-ruler';
export * from './scrolling-module';
export * from './viewport-ruler';
export * from './virtual-scroll-viewport';
21 changes: 17 additions & 4 deletions src/cdk/scrolling/scrolling-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,28 @@
* found in the LICENSE file at https://angular.io/license
*/

import {PlatformModule} from '@angular/cdk/platform';
import {NgModule} from '@angular/core';
import {CdkVirtualForOf} from './virtual-for-of';
import {SCROLL_DISPATCHER_PROVIDER} from './scroll-dispatcher';
import {CdkScrollable} from './scrollable';
import {PlatformModule} from '@angular/cdk/platform';
import {CdkScrollable} from './scrollable';
import {CdkVirtualScrollFixedSize} from './virtual-scroll-fixed-size';
import {CdkVirtualScrollViewport} from './virtual-scroll-viewport';

@NgModule({
imports: [PlatformModule],
exports: [CdkScrollable],
declarations: [CdkScrollable],
exports: [
CdkVirtualForOf,
CdkScrollable,
CdkVirtualScrollFixedSize,
CdkVirtualScrollViewport,
],
declarations: [
CdkVirtualForOf,
CdkScrollable,
CdkVirtualScrollFixedSize,
CdkVirtualScrollViewport,
],
providers: [SCROLL_DISPATCHER_PROVIDER],
})
export class ScrollDispatchModule {}
3 changes: 2 additions & 1 deletion src/cdk/scrolling/tsconfig-build.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "../tsconfig-build",
"files": [
"public-api.ts"
"public-api.ts",
"../typings.d.ts"
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
Expand Down
1 change: 1 addition & 0 deletions src/cdk/scrolling/typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare var module: {id: string};
Loading