"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/cdk/scrolling/virtual-for-of.ts" between
material2-7.3.3.tar.gz and material2-7.3.4.tar.gz

About: material2 offers Material Design components for Angular.

virtual-for-of.ts  (material2-7.3.3):virtual-for-of.ts  (material2-7.3.4)
skipping to change at line 293 skipping to change at line 293
} }
} }
/** Apply changes to the DOM. */ /** Apply changes to the DOM. */
private _applyChanges(changes: IterableChanges<T>) { private _applyChanges(changes: IterableChanges<T>) {
// Rearrange the views to put them in the right location. // Rearrange the views to put them in the right location.
changes.forEachOperation((record: IterableChangeRecord<T>, changes.forEachOperation((record: IterableChangeRecord<T>,
adjustedPreviousIndex: number | null, adjustedPreviousIndex: number | null,
currentIndex: number | null) => { currentIndex: number | null) => {
if (record.previousIndex == null) { // Item added. if (record.previousIndex == null) { // Item added.
const view = this._getViewForNewItem(); const view = this._insertViewForNewItem(currentIndex!);
this._viewContainerRef.insert(view, currentIndex!);
view.context.$implicit = record.item; view.context.$implicit = record.item;
} else if (currentIndex == null) { // Item removed. } else if (currentIndex == null) { // Item removed.
this._cacheView(this._viewContainerRef.detach(adjustedPreviousIndex!) as this._cacheView(this._detachView(adjustedPreviousIndex !));
EmbeddedViewRef<CdkVirtualForOfContext<T>>);
} else { // Item moved. } else { // Item moved.
const view = this._viewContainerRef.get(adjustedPreviousIndex!) as const view = this._viewContainerRef.get(adjustedPreviousIndex!) as
EmbeddedViewRef<CdkVirtualForOfContext<T>>; EmbeddedViewRef<CdkVirtualForOfContext<T>>;
this._viewContainerRef.move(view, currentIndex); this._viewContainerRef.move(view, currentIndex);
view.context.$implicit = record.item; view.context.$implicit = record.item;
} }
}); });
// Update $implicit for any items that had an identity change. // Update $implicit for any items that had an identity change.
changes.forEachIdentityChange((record: IterableChangeRecord<T>) => { changes.forEachIdentityChange((record: IterableChangeRecord<T>) => {
skipping to change at line 343 skipping to change at line 341
// destroy the view on its own, otherwise destroy it through the // destroy the view on its own, otherwise destroy it through the
// container to ensure that all the references are removed. // container to ensure that all the references are removed.
if (index === -1) { if (index === -1) {
view.destroy(); view.destroy();
} else { } else {
this._viewContainerRef.remove(index); this._viewContainerRef.remove(index);
} }
} }
} }
/** Get a view for a new item, either from the cache or by creating a new one. /** Inserts a view for a new item, either from the cache or by creating a new
*/ one. */
private _getViewForNewItem(): EmbeddedViewRef<CdkVirtualForOfContext<T>> { private _insertViewForNewItem(index: number): EmbeddedViewRef<CdkVirtualForOfC
return this._templateCache.pop() || this._viewContainerRef.createEmbeddedVie ontext<T>> {
w(this._template, { return this._insertViewFromCache(index) || this._createEmbeddedViewAt(index)
$implicit: null!, ;
cdkVirtualForOf: this._cdkVirtualForOf,
index: -1,
count: -1,
first: false,
last: false,
odd: false,
even: false
});
} }
/** Update the computed properties on the `CdkVirtualForOfContext`. */ /** Update the computed properties on the `CdkVirtualForOfContext`. */
private _updateComputedContextProperties(context: CdkVirtualForOfContext<any>) { private _updateComputedContextProperties(context: CdkVirtualForOfContext<any>) {
context.first = context.index === 0; context.first = context.index === 0;
context.last = context.index === context.count - 1; context.last = context.index === context.count - 1;
context.even = context.index % 2 === 0; context.even = context.index % 2 === 0;
context.odd = !context.even; context.odd = !context.even;
} }
/** Creates a new embedded view and moves it to the given index */
private _createEmbeddedViewAt(index: number): EmbeddedViewRef<CdkVirtualForOfC
ontext<T>> {
const view = this._viewContainerRef.createEmbeddedView(this._template, {
$implicit: null!,
cdkVirtualForOf: this._cdkVirtualForOf,
index: -1,
count: -1,
first: false,
last: false,
odd: false,
even: false
});
if (index < this._viewContainerRef.length) {
this._viewContainerRef.move(view, index);
}
return view;
}
/** Inserts a recycled view from the cache at the given index. */
private _insertViewFromCache(index: number): EmbeddedViewRef<CdkVirtualForOfCo
ntext<T>>|null {
const cachedView = this._templateCache.pop();
if (cachedView) {
this._viewContainerRef.insert(cachedView, index);
}
return cachedView || null;
}
/** Detaches the embedded view at the given index. */
private _detachView(index: number): EmbeddedViewRef<CdkVirtualForOfContext<T>>
{
return this._viewContainerRef.detach(index) as
EmbeddedViewRef<CdkVirtualForOfContext<T>>;
}
} }
 End of changes. 4 change blocks. 
18 lines changed or deleted 44 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)