mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
fix(label): do not animate float labels on initial load (#16036)
This commit is contained in:
@ -79,3 +79,7 @@
|
|||||||
:host-context(.item-has-value).label-floating {
|
:host-context(.item-has-value).label-floating {
|
||||||
@include transform(translate3d(0, 0, 0), scale(.8));
|
@include transform(translate3d(0, 0, 0), scale(.8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:host(.label-no-animate.label-floating) {
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Component, ComponentInterface, Element, Event, EventEmitter, Prop, Watch } from '@stencil/core';
|
import { Component, ComponentInterface, Element, Event, EventEmitter, Prop, State, Watch } from '@stencil/core';
|
||||||
|
|
||||||
import { Color, Mode, StyleEvent } from '../../interface';
|
import { Color, Mode, StyleEvent } from '../../interface';
|
||||||
import { createColorClasses } from '../../utils/theme';
|
import { createColorClasses } from '../../utils/theme';
|
||||||
@ -38,8 +38,20 @@ export class Label implements ComponentInterface {
|
|||||||
*/
|
*/
|
||||||
@Event() ionStyle!: EventEmitter<StyleEvent>;
|
@Event() ionStyle!: EventEmitter<StyleEvent>;
|
||||||
|
|
||||||
|
@State() noAnimate = false;
|
||||||
|
|
||||||
|
componentWillLoad() {
|
||||||
|
this.noAnimate = (this.position === 'floating');
|
||||||
|
}
|
||||||
|
|
||||||
componentDidLoad() {
|
componentDidLoad() {
|
||||||
this.positionChanged();
|
this.positionChanged();
|
||||||
|
|
||||||
|
if (this.noAnimate) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.noAnimate = false;
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Watch('position')
|
@Watch('position')
|
||||||
@ -57,6 +69,7 @@ export class Label implements ComponentInterface {
|
|||||||
class: {
|
class: {
|
||||||
...createColorClasses(this.color),
|
...createColorClasses(this.color),
|
||||||
[`label-${position}`]: !!position,
|
[`label-${position}`]: !!position,
|
||||||
|
[`label-no-animate`]: (this.noAnimate)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<ion-label>Default</ion-label>
|
<ion-label>Default</ion-label>
|
||||||
<ion-label>Wrap label this label just goes on and on and on</ion-label>
|
<ion-label>Wrap label this label just goes on and on and on</ion-label>
|
||||||
<ion-label position="fixed">Fixed</ion-label>
|
<ion-label position="fixed">Fixed</ion-label>
|
||||||
<ion-label position="floating">Floating</ion-label>
|
<ion-label position="floating" style="margin-bottom: 30px;">Floating</ion-label>
|
||||||
<ion-label position="stacked">Stacked</ion-label>
|
<ion-label position="stacked">Stacked</ion-label>
|
||||||
|
|
||||||
<h1>Colors</h1>
|
<h1>Colors</h1>
|
||||||
|
Reference in New Issue
Block a user