Does styling opacities conflict with animation opacities?

Richard Bair richard.bair at oracle.com
Thu Aug 30 08:47:37 PDT 2012


>> The problem here is that whenever you set a property both from CSS and from code, code not only will always win, but will disable that property from being set from CSS henceforth. We used to have the rule that "last applied wins" or "CSS always wins", and this led to very unsettling behavior to developers. The current behavior appears to be much more intuitive. However it means that until CSS animation support is added, you won't be able to both style from CSS and animate the styled property :-(.
> 
> This is not entirely correct. If I have
> 
> Rectangle rect = new Rectangle(10,10);
> rect.getStyleClass().add("rect");
> rect.setOpacity(.5);
> 
> And this CSS in an inline style or an author stylesheet:
> 
> .rect { -fx-opacity: .8; } 
> 
> Then the opacity will be set to 80% since an inline or author style overrides a user set style. If the same style was in a user agent stylesheet, then the user agent style would be overridden by the call to setOpacity (more correctly, the style will not override the call to setOpacity). 

You are right of course. We only disable CSS updates for properties that were set in code for the user agent stylesheet, not for author stylesheets.



More information about the openjfx-dev mailing list