@pumpkin-tech/pumpkin-tech-ng 0.2.9 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -104,12 +104,14 @@ class PtechGridDirective {
104
104
  display = 'grid';
105
105
  columns = 'repeat(12, minmax(0, 1fr))';
106
106
  activeBp = null;
107
+ viewportBp = null;
107
108
  constructor(bp) {
108
109
  this.bp = bp;
109
110
  this.bp.observe(Object.values(MEDIA$1))
110
111
  .pipe(takeUntil(this.destroy$))
111
112
  .subscribe(state => {
112
- this.activeBp = this.pickActive(state.breakpoints);
113
+ this.viewportBp = this.pickActive(state.breakpoints);
114
+ this.activeBp = this.viewportBp;
113
115
  this.updateCols();
114
116
  });
115
117
  }
@@ -213,6 +215,8 @@ class PtechColDirective {
213
215
  ptechColLg;
214
216
  ptechColXl;
215
217
  activeBp = null;
218
+ viewportBp = null;
219
+ containerBp = null;
216
220
  activeSource = null;
217
221
  gridColumn = 'auto / span 12';
218
222
  minWidth = '0';
@@ -226,9 +230,14 @@ class PtechColDirective {
226
230
  .subscribe(s => {
227
231
  if (this.ptechColMode === 'container')
228
232
  return;
229
- if (this.ptechColMode === 'auto' && this.activeSource === 'container')
233
+ this.viewportBp = this.pickActive(s.breakpoints);
234
+ if (this.ptechColMode === 'auto') {
235
+ this.activeBp = this.pickAutoBp();
236
+ this.activeSource = this.containerBp ? 'container' : 'viewport';
237
+ this.updateSpan();
230
238
  return;
231
- this.activeBp = this.pickActive(s.breakpoints);
239
+ }
240
+ this.activeBp = this.viewportBp;
232
241
  this.activeSource = 'viewport';
233
242
  this.updateSpan();
234
243
  });
@@ -250,11 +259,23 @@ class PtechColDirective {
250
259
  : w >= 960 ? 'md'
251
260
  : w >= 600 ? 'sm'
252
261
  : 'xs';
253
- if (bp !== this.activeBp || this.activeSource !== 'container') {
254
- this.activeBp = bp;
255
- this.activeSource = 'container';
256
- this.ngZone.run(() => this.updateSpan());
257
- }
262
+ this.containerBp = bp;
263
+ this.ngZone.run(() => {
264
+ if (this.ptechColMode === 'auto') {
265
+ const nextBp = this.pickAutoBp();
266
+ if (nextBp !== this.activeBp || this.activeSource !== 'container') {
267
+ this.activeBp = nextBp;
268
+ this.activeSource = 'container';
269
+ this.updateSpan();
270
+ }
271
+ return;
272
+ }
273
+ if (this.ptechColMode === 'container' && (bp !== this.activeBp || this.activeSource !== 'container')) {
274
+ this.activeBp = bp;
275
+ this.activeSource = 'container';
276
+ this.updateSpan();
277
+ }
278
+ });
258
279
  });
259
280
  });
260
281
  this.ro.observe(gridParent);
@@ -283,6 +304,14 @@ class PtechColDirective {
283
304
  return key;
284
305
  return null;
285
306
  }
307
+ pickAutoBp() {
308
+ const rank = { xs: 0, sm: 1, md: 2, lg: 3, xl: 4 };
309
+ if (!this.viewportBp)
310
+ return this.containerBp;
311
+ if (!this.containerBp)
312
+ return this.viewportBp;
313
+ return rank[this.viewportBp] <= rank[this.containerBp] ? this.viewportBp : this.containerBp;
314
+ }
286
315
  updateSpan() {
287
316
  const span = this.resolveColForBp();
288
317
  if (span === this.lastSpan)