"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/cdk/tree/padding.ts" between
material2-7.3.4.tar.gz and material2-7.3.5.tar.gz

About: material2 offers Material Design components for Angular.

padding.ts  (material2-7.3.4):padding.ts  (material2-7.3.5)
skipping to change at line 27 skipping to change at line 27
const cssUnitPattern = /([A-Za-z%]+)$/; const cssUnitPattern = /([A-Za-z%]+)$/;
/** /**
* Indent for the children tree dataNodes. * Indent for the children tree dataNodes.
* This directive will add left-padding to the node to show hierarchy. * This directive will add left-padding to the node to show hierarchy.
*/ */
@Directive({ @Directive({
selector: '[cdkTreeNodePadding]', selector: '[cdkTreeNodePadding]',
}) })
export class CdkTreeNodePadding<T> implements OnDestroy { export class CdkTreeNodePadding<T> implements OnDestroy {
/** Current padding value applied to the element. Used to avoid unnecessarily
hitting the DOM. */
private _currentPadding: string|null;
/** Subject that emits when the component has been destroyed. */ /** Subject that emits when the component has been destroyed. */
private _destroyed = new Subject<void>(); private _destroyed = new Subject<void>();
/** CSS units used for the indentation value. */ /** CSS units used for the indentation value. */
indentUnits = 'px'; indentUnits = 'px';
/** The level of depth of the tree node. The padding will be `level * indent` pixels. */ /** The level of depth of the tree node. The padding will be `level * indent` pixels. */
@Input('cdkTreeNodePadding') @Input('cdkTreeNodePadding')
get level(): number { return this._level; } get level(): number { return this._level; }
set level(value: number) { set level(value: number) {
skipping to change at line 71 skipping to change at line 74
} }
_indent: number = 40; _indent: number = 40;
constructor(private _treeNode: CdkTreeNode<T>, constructor(private _treeNode: CdkTreeNode<T>,
private _tree: CdkTree<T>, private _tree: CdkTree<T>,
private _renderer: Renderer2, private _renderer: Renderer2,
private _element: ElementRef<HTMLElement>, private _element: ElementRef<HTMLElement>,
@Optional() private _dir: Directionality) { @Optional() private _dir: Directionality) {
this._setPadding(); this._setPadding();
if (_dir) { if (_dir) {
_dir.change.pipe(takeUntil(this._destroyed)).subscribe(() => this._setPadd ing()); _dir.change.pipe(takeUntil(this._destroyed)).subscribe(() => this._setPadd ing(true));
} }
// In Ivy the indentation binding might be set before the tree node's data h
as been added,
// which means that we'll miss the first render. We have to subscribe to cha
nges in the
// data to ensure that everything is up to date.
_treeNode._dataChanges.subscribe(() => this._setPadding());
} }
ngOnDestroy() { ngOnDestroy() {
this._destroyed.next(); this._destroyed.next();
this._destroyed.complete(); this._destroyed.complete();
} }
/** The padding indent value for the tree node. Returns a string with px numbe rs if not null. */ /** The padding indent value for the tree node. Returns a string with px numbe rs if not null. */
_paddingIndent(): string|null { _paddingIndent(): string|null {
const nodeLevel = (this._treeNode.data && this._tree.treeControl.getLevel) const nodeLevel = (this._treeNode.data && this._tree.treeControl.getLevel)
? this._tree.treeControl.getLevel(this._treeNode.data) ? this._tree.treeControl.getLevel(this._treeNode.data)
: null; : null;
const level = this._level || nodeLevel; const level = this._level || nodeLevel;
return level ? `${level * this._indent}${this.indentUnits}` : null; return level ? `${level * this._indent}${this.indentUnits}` : null;
} }
_setPadding() { _setPadding(forceChange = false) {
const element = this._element.nativeElement;
const padding = this._paddingIndent(); const padding = this._paddingIndent();
const paddingProp = this._dir && this._dir.value === 'rtl' ? 'paddingRight'
: 'paddingLeft';
const resetProp = paddingProp === 'paddingLeft' ? 'paddingRight' : 'paddingL
eft';
this._renderer.setStyle(element, paddingProp, padding); if (padding !== this._currentPadding || forceChange) {
this._renderer.setStyle(element, resetProp, ''); const element = this._element.nativeElement;
const paddingProp = this._dir && this._dir.value === 'rtl' ? 'paddingRight
' : 'paddingLeft';
const resetProp = paddingProp === 'paddingLeft' ? 'paddingRight' : 'paddin
gLeft';
this._renderer.setStyle(element, paddingProp, padding);
this._renderer.setStyle(element, resetProp, null);
this._currentPadding = padding;
}
} }
} }
 End of changes. 6 change blocks. 
9 lines changed or deleted 23 lines changed or added

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