source: trip-planner-front/node_modules/@angular/cdk/esm2015/collections/recycle-view-repeater-strategy.js@ bdd6491

Last change on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 17.2 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8/**
9 * A repeater that caches views when they are removed from a
10 * {@link ViewContainerRef}. When new items are inserted into the container,
11 * the repeater will reuse one of the cached views instead of creating a new
12 * embedded view. Recycling cached views reduces the quantity of expensive DOM
13 * inserts.
14 *
15 * @template T The type for the embedded view's $implicit property.
16 * @template R The type for the item in each IterableDiffer change record.
17 * @template C The type for the context passed to each embedded view.
18 */
19export class _RecycleViewRepeaterStrategy {
20 constructor() {
21 /**
22 * The size of the cache used to store unused views.
23 * Setting the cache size to `0` will disable caching. Defaults to 20 views.
24 */
25 this.viewCacheSize = 20;
26 /**
27 * View cache that stores embedded view instances that have been previously stamped out,
28 * but don't are not currently rendered. The view repeater will reuse these views rather than
29 * creating brand new ones.
30 *
31 * TODO(michaeljamesparsons) Investigate whether using a linked list would improve performance.
32 */
33 this._viewCache = [];
34 }
35 /** Apply changes to the DOM. */
36 applyChanges(changes, viewContainerRef, itemContextFactory, itemValueResolver, itemViewChanged) {
37 // Rearrange the views to put them in the right location.
38 changes.forEachOperation((record, adjustedPreviousIndex, currentIndex) => {
39 let view;
40 let operation;
41 if (record.previousIndex == null) { // Item added.
42 const viewArgsFactory = () => itemContextFactory(record, adjustedPreviousIndex, currentIndex);
43 view = this._insertView(viewArgsFactory, currentIndex, viewContainerRef, itemValueResolver(record));
44 operation = view ? 1 /* INSERTED */ : 0 /* REPLACED */;
45 }
46 else if (currentIndex == null) { // Item removed.
47 this._detachAndCacheView(adjustedPreviousIndex, viewContainerRef);
48 operation = 3 /* REMOVED */;
49 }
50 else { // Item moved.
51 view = this._moveView(adjustedPreviousIndex, currentIndex, viewContainerRef, itemValueResolver(record));
52 operation = 2 /* MOVED */;
53 }
54 if (itemViewChanged) {
55 itemViewChanged({
56 context: view === null || view === void 0 ? void 0 : view.context,
57 operation,
58 record,
59 });
60 }
61 });
62 }
63 detach() {
64 for (const view of this._viewCache) {
65 view.destroy();
66 }
67 this._viewCache = [];
68 }
69 /**
70 * Inserts a view for a new item, either from the cache or by creating a new
71 * one. Returns `undefined` if the item was inserted into a cached view.
72 */
73 _insertView(viewArgsFactory, currentIndex, viewContainerRef, value) {
74 const cachedView = this._insertViewFromCache(currentIndex, viewContainerRef);
75 if (cachedView) {
76 cachedView.context.$implicit = value;
77 return undefined;
78 }
79 const viewArgs = viewArgsFactory();
80 return viewContainerRef.createEmbeddedView(viewArgs.templateRef, viewArgs.context, viewArgs.index);
81 }
82 /** Detaches the view at the given index and inserts into the view cache. */
83 _detachAndCacheView(index, viewContainerRef) {
84 const detachedView = viewContainerRef.detach(index);
85 this._maybeCacheView(detachedView, viewContainerRef);
86 }
87 /** Moves view at the previous index to the current index. */
88 _moveView(adjustedPreviousIndex, currentIndex, viewContainerRef, value) {
89 const view = viewContainerRef.get(adjustedPreviousIndex);
90 viewContainerRef.move(view, currentIndex);
91 view.context.$implicit = value;
92 return view;
93 }
94 /**
95 * Cache the given detached view. If the cache is full, the view will be
96 * destroyed.
97 */
98 _maybeCacheView(view, viewContainerRef) {
99 if (this._viewCache.length < this.viewCacheSize) {
100 this._viewCache.push(view);
101 }
102 else {
103 const index = viewContainerRef.indexOf(view);
104 // The host component could remove views from the container outside of
105 // the view repeater. It's unlikely this will occur, but just in case,
106 // destroy the view on its own, otherwise destroy it through the
107 // container to ensure that all the references are removed.
108 if (index === -1) {
109 view.destroy();
110 }
111 else {
112 viewContainerRef.remove(index);
113 }
114 }
115 }
116 /** Inserts a recycled view from the cache at the given index. */
117 _insertViewFromCache(index, viewContainerRef) {
118 const cachedView = this._viewCache.pop();
119 if (cachedView) {
120 viewContainerRef.insert(cachedView, index);
121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ljbGVkIHZpZXcgZnJvbSB0aGUgY2FjaGUgYXQgdGhlIGdpdmVuIGluZGV4LiAqL1xuICBwcml2YXRlIF9pbnNlcnRWaWV3RnJvbUNhY2hlKGluZGV4OiBudW1iZXIsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld0NvbnRhaW5lclJlZjogVmlld0NvbnRhaW5lclJlZik6IEVtYmVkZGVkVmlld1JlZjxDPiB8IG51bGwge1xuICAgIGNvbnN0IGNhY2hlZFZpZXcgPSB0aGlzLl92aWV3Q2FjaGUucG9wKCk7XG4gICAgaWYgKGNhY2hlZFZpZXcpIHtcbiAgICAgIHZpZXdDb250YWluZXJSZWYuaW5zZXJ0KGNhY2hlZFZpZXcsIGluZGV4KTtcbiAgICB9XG4gICAgcmV0dXJuIGNhY2hlZFZpZXcgfHwgbnVsbDtcbiAgfVxufVxuIl19
Note: See TracBrowser for help on using the repository browser.