Angular 2 re-apply [ngStyle] after animation ends -
i have set of images, i'm positioning absolutely next each other. this, have on each image element:
[ngstyle]="{ 'left': ((i % 5)*150) + 'px', 'top': (math.floor(i / 5)*150) + 'px' }"
where index. when click 1 of images, brought center of page. this, have following animation states in component:
state('visible', style({ opacity: 1, transform: 'scale(1)', 'z-index': 0, 'box-shadow': 'none', 'transform-origin': 'initial' })), state('clicked',style({ transform: 'scale(3)', 'transform-origin': '0 0', top: '25px', left: '150px', opacity: 1, 'z-index': 2, 'box-shadow': '0 0 20px 10px rgba(0,0,0,0.4)' })),
this works when click on image. however, when click on image again, transition 'clicked'=>'visible'. since [ngstyle] overriden 'clicked' styling, when goes 'visible' state, left , top styling [ngstyle] applied gone, , every image goes top left.
things i've tried:
1) variables in animation -> not supported angular
2) intercepting callback of animation starting 'clicked'=>'visible' , re-adding in top , left styling on element => adds styling once animation over. image moves top left jumps spot (ew)
3) not using position absolute default images => when move images middle of page, every other element jumps 1 bad.
Comments
Post a Comment