-
Notifications
You must be signed in to change notification settings - Fork 768
fix(lib): support API directive queries #290
Conversation
ea7da67
to
6944d31
Compare
Snapshot of Splitter Demoissue.266.demo.ts<div fxLayout="row" style="height:500px" ngxSplit="row">
<div fxFlex="30%" ngxSplitArea class="c1r1" > </div>
<div class="handle handle-row" ngxSplitHandle>
<i class="material-icons"></i>
</div>
<div fxFlex="70%" ngxSplitArea>
<div fxLayout="column" fxFlexFill ngxSplit="column">
<div fxFlex="50%" ngxSplitArea class="c2r1_body" > </div>
<div class="handle handle-column" ngxSplitHandle>
<i class="material-icons"></i>
</div>
<div fxFlex="50%" ngxSplitArea class="c2r2" > </div>
</div>
</div>
</div> split.directive.ts onDrag({x, y}): void {
const dragAmount = (this.direction === 'row') ? x : y;
this.areas.forEach((area, i) => {
const flex = (area.flex as FlexDirective);
const delta = (i === 0) ? dragAmount : -dragAmount;
const currentValue = flex.activatedValue;
// Update Flex-Layout value to build/inject new flexbox CSS
flex.activatedValue = this.calculateSize(currentValue, delta);
});
} @amcdnl - would you mind reviewing ? |
3aaf0e0
to
b8a5852
Compare
@kara - please review. |
@ThomasBurleson - This looks awesome! |
7e05942
to
b9be116
Compare
@jelbourn - please presubmit. |
|
src/lib/flexbox/api/base.ts
Outdated
|
||
let activatedKey = this._mqActivation.activatedInputKey; | ||
this._inputMap[activatedKey] = value; | ||
this._updateStyle(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this logic can be simplified:
if (this._mqActivation) {
this._inputMap[this._mqActivation.activatedInputKey] = value;
}
this._updateStyle(value);
src/lib/flexbox/api/base.ts
Outdated
@@ -65,10 +91,17 @@ export abstract class BaseFxDirective implements OnDestroy { | |||
// ********************************************* | |||
|
|||
/** | |||
* Abstract method... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs documentation, also should it throw an error that it needs to be implemented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for drawing my attention to this. This was only a partial (in fact poor) solution.
I found another more robust approach.
src/lib/flexbox/api/base.ts
Outdated
value = value || 'row'; | ||
this._applyStyleToElements(buildLayoutCSS(value), [target]); | ||
} | ||
let value = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: single quotes
src/lib/flexbox/api/base.ts
Outdated
return direction || styles[key]; | ||
}, null); | ||
|
||
let immediateValue = findDirection(target['style']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this instead of target.style
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cannot recall the reasoning. Will fix.
src/lib/flexbox/api/base.ts
Outdated
}, null); | ||
|
||
let immediateValue = findDirection(target['style']); | ||
value = immediateValue || findDirection(getComputedStyle(target as Element)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason that target isn't an Element
in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this._elementRef.nativeElement
is typed as any
... so I cast here to document explicitly.
src/lib/flexbox/api/base.ts
Outdated
|
||
return value ? value.trim() : "row"; | ||
return value ? value.trim() : "row"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: single quotes
src/lib/flexbox/api/flex.spec.ts
Outdated
@@ -126,15 +128,15 @@ describe('flex directive', () => { | |||
`); | |||
fixture.detectChanges(); | |||
let element = queryFor(fixture, "[fxFlex]")[0].nativeElement; | |||
let parent = queryFor(fixture, ".test")[0].nativeElement; | |||
let parent = queryFor(fixture, ".test")[0].nativeElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
single quotes
src/lib/flexbox/api/flex.spec.ts
Outdated
@@ -149,11 +151,11 @@ describe('flex directive', () => { | |||
`); | |||
fixture.detectChanges(); | |||
let element = queryFor(fixture, "[fxFlex]")[0].nativeElement; | |||
let parent = queryFor(fixture, ".parent")[0].nativeElement; | |||
let parent = queryFor(fixture, ".parent")[0].nativeElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
single quotes
src/lib/flexbox/api/base.ts
Outdated
@@ -65,10 +91,17 @@ export abstract class BaseFxDirective implements OnDestroy { | |||
// ********************************************* | |||
|
|||
/** | |||
* Abstract method... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidentally deleted Miles comments: docs needed and throw exception if not overriden
src/lib/flexbox/api/base.ts
Outdated
|
||
let activatedKey = this._mqActivation.activatedInputKey; | ||
this._inputMap[activatedKey] = value; | ||
this._updateStyle(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidently deleted @mmalerba comments. Refactor ing
src/lib/flexbox/api/base.ts
Outdated
return direction || styles[key]; | ||
}, null); | ||
|
||
let immediateValue = findDirection(target['style']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cannot recall the reasoning. Will fix.
src/lib/flexbox/api/base.ts
Outdated
}, null); | ||
|
||
let immediateValue = findDirection(target['style']); | ||
value = immediateValue || findDirection(getComputedStyle(target as Element)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this._elementRef.nativeElement
is typed as any
... so I cast here to document explicitly.
src/lib/flexbox/api/base.ts
Outdated
@@ -65,10 +91,17 @@ export abstract class BaseFxDirective implements OnDestroy { | |||
// ********************************************* | |||
|
|||
/** | |||
* Abstract method... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for drawing my attention to this. This was only a partial (in fact poor) solution.
I found another more robust approach.
b9be116
to
db97d73
Compare
@mmalerba - updated with all your suggested changes. |
* support DI of flexbox/api Directive classes * implement Directive method `activatedValue` getter/setter * to imperatively read current activated input value * to write API values with immediate style updates * implement demo using splitters (ngxSplit) with fxLayout and fxFlex layouts
db97d73
to
2ebb335
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
activatedValue
getter/setterFixes #266.