Skip to content

Commit

Permalink
start transitions only when not in initial CSS state
Browse files Browse the repository at this point in the history
  • Loading branch information
mstr2 committed Oct 21, 2024
1 parent b993d4e commit 8fe7a7c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public StyleableBooleanProperty(boolean initialValue) {
/** {@inheritDoc} */
@Override
public void applyStyle(StyleOrigin origin, Boolean v) {
TransitionDefinition transition = this.origin != null && getBean() instanceof Node node ?
// If the value is applied for the first time, we don't start a transition.
TransitionDefinition transition = getBean() instanceof Node node && !NodeHelper.isInitialCssState(node) ?
NodeHelper.findTransitionDefinition(node, getCssMetaData()) : null;

boolean newValue = v != null && v;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ public StyleableDoubleProperty(double initialValue) {
/** {@inheritDoc} */
@Override
public void applyStyle(StyleOrigin origin, Number v) {
// If this.origin == null, we're setting the value for the first time.
// No transition should be started in this case.
TransitionDefinition transition = this.origin != null && getBean() instanceof Node node ?
// If the value is applied for the first time, we don't start a transition.
TransitionDefinition transition = getBean() instanceof Node node && !NodeHelper.isInitialCssState(node) ?
NodeHelper.findTransitionDefinition(node, getCssMetaData()) : null;

double newValue = v != null ? v.doubleValue() : 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public StyleableFloatProperty(float initialValue) {
/** {@inheritDoc} */
@Override
public void applyStyle(StyleOrigin origin, Number v) {
TransitionDefinition transition = this.origin != null && getBean() instanceof Node node ?
// If the value is applied for the first time, we don't start a transition.
TransitionDefinition transition = getBean() instanceof Node node && !NodeHelper.isInitialCssState(node) ?
NodeHelper.findTransitionDefinition(node, getCssMetaData()) : null;

float newValue = v != null ? v.floatValue() : 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public StyleableIntegerProperty(int initialValue) {
/** {@inheritDoc} */
@Override
public void applyStyle(StyleOrigin origin, Number v) {
TransitionDefinition transition = this.origin != null && getBean() instanceof Node node ?
// If the value is applied for the first time, we don't start a transition.
TransitionDefinition transition = getBean() instanceof Node node && !NodeHelper.isInitialCssState(node) ?
NodeHelper.findTransitionDefinition(node, getCssMetaData()) : null;

int newValue = v != null ? v.intValue() : 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ public StyleableLongProperty(long initialValue) {
/** {@inheritDoc} */
@Override
public void applyStyle(StyleOrigin origin, Number v) {
// If this.origin == null, we're setting the value for the first time.
// No transition should be started in this case.
TransitionDefinition transition = this.origin != null && getBean() instanceof Node node ?
// If the value is applied for the first time, we don't start a transition.
TransitionDefinition transition = getBean() instanceof Node node && !NodeHelper.isInitialCssState(node) ?
NodeHelper.findTransitionDefinition(node, getCssMetaData()) : null;

long newValue = v != null ? v.longValue() : 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,9 @@ public void applyStyle(StyleOrigin origin, T newValue) {
* @param metadata the CSS metadata of the value
*/
private void applyValue(T oldValue, T newValue, CssMetaData<? extends Styleable, T> metadata) {
// If this.origin == null, we're setting the value for the first time.
// No transition should be started in this case.
// If the value is applied for the first time, we don't start a transition.
TransitionDefinition transition =
this.origin != null && getBean() instanceof Node node ?
getBean() instanceof Node node && !NodeHelper.isInitialCssState(node) ?
NodeHelper.findTransitionDefinition(node, metadata) : null;

// We only start a new transition if the new target value is different from the target
Expand Down Expand Up @@ -146,10 +145,9 @@ private void applyValue(T oldValue, T newValue, CssMetaData<? extends Styleable,
private void applyComponents(T oldValue, T newValue,
CssMetaData<? extends Styleable, T> metadata,
SubPropertyConverter<T> converter) {
// If this.origin == null, we're setting the value for the first time.
// No transition should be started in this case.
// If the value is applied for the first time, we don't start a transition.
Map<CssMetaData<? extends Styleable, ?>, TransitionDefinition> transitions =
this.origin != null && getBean() instanceof Node node ?
getBean() instanceof Node node && !NodeHelper.isInitialCssState(node) ?
NodeHelper.findTransitionDefinitions(node, metadata) : null;

List<CssMetaData<? extends Styleable, ?>> subMetadata = metadata.getSubProperties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@ public StyleableStringProperty(String initialValue) {
/** {@inheritDoc} */
@Override
public void applyStyle(StyleOrigin origin, String newValue) {
// If this.origin == null, we're setting the value for the first time.
// No transition should be started in this case.
// If the value is applied for the first time, we don't start a transition.
TransitionDefinition transition =
this.origin != null && getBean() instanceof Node node ?
getBean() instanceof Node node && !NodeHelper.isInitialCssState(node) ?
NodeHelper.findTransitionDefinition(node, getCssMetaData()) : null;

if (transition == null) {
Expand Down

0 comments on commit 8fe7a7c

Please sign in to comment.