Skip to content

binding multiple style properties #3709

@sumigoma

Description

@sumigoma

Is there an easier way to bind multiple style properties? It would be nice to be able to pass in an object into a la -> [style] = "styleObj" where styleObj={top:'3px', left:'3px'}
where the properties get mapped to the appropriate DOM object properties, or some other more concise syntax than this below.

<div class="handle handle-w" [style.top]="'50%'" [style.left]="-r/zoom+'px'" [style.width]="2*r/zoom+'px'" [style.height]="2*r/zoom+'px'" [style.border-radius]="r/zoom+'px'"></div>
<div class="handle handle-nw" [style.top]="-r/zoom+'px'" [style.left]="-r/zoom+'px'" [style.width]="2*r/zoom+'px'" [style.height]="2*r/zoom+'px'" [style.border-radius]="r/zoom+'px'"></div>
<div class="handle handle-n" [style.top]="-r/zoom+'px'" [style.left]="'50%'" [style.width]="2*r/zoom+'px'" [style.height]="2*r/zoom+'px'" [style.border-radius]="r/zoom+'px'"></div>    
<div class="handle handle-ne" [style.top]="-r/zoom+'px'" [style.right]="-r/zoom+'px'" [style.width]="2*r/zoom+'px'" [style.height]="2*r/zoom+'px'" [style.border-radius]="r/zoom+'px'"></div>
<div class="handle handle-e" [style.top]="'50%'" [style.right]="-r/zoom+'px'" [style.width]="2*r/zoom+'px'" [style.height]="2*r/zoom+'px'" [style.border-radius]="r/zoom+'px'"></div>
<div class="handle handle-se" [style.bottom]="-r/zoom+'px'" [style.right]="-r/zoom+'px'" [style.width]="2*r/zoom+'px'" [style.height]="2*r/zoom+'px'" [style.border-radius]="r/zoom+'px'"></div>    
<div class="handle handle-s" [style.bottom]="-r/zoom+'px'" [style.left]="'50%'" [style.width]="2*r/zoom+'px'" [style.height]="2*r/zoom+'px'" [style.border-radius]="r/zoom+'px'"></div>
<div class="handle handle-sw" [style.bottom]="-r/zoom+'px'" [style.left]="-r/zoom+'px'" [style.width]="2*r/zoom+'px'" [style.height]="2*r/zoom+'px'" [style.border-radius]="r/zoom+'px'"></div>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions