Class FlashClassAction

java.lang.Object
com.vaadin.flow.component.trigger.internal.Action
com.vaadin.flow.component.trigger.internal.FlashClassAction
All Implemented Interfaces:
Serializable

public class FlashClassAction extends Action
Briefly adds a CSS class to a target element when the bound trigger fires, removing it again when the associated CSS animation ends. Pure client-side — no server round-trip.

Trigger-driven counterpart to Element.flashClass(String): the Element method is the server-initiated entry point (e.g. flashing a highlight when a signal value changes); this action is for wiring the same flash to a client-side trigger so the gesture-to-animation path stays in the browser.

The class name to flash can be either a literal (constant, serialised at build time) or an Action.Input that produces the name on the client when the trigger fires — for example, sourcing the name from a property on the host element.

Common idioms:

  • Flash a fixed class on click: new FlashClassAction(panel, "highlight")
  • Flash a class whose name comes from a property: new FlashClassAction(panel, new PropertyInput<>(other, "flashClassName", String.class))
For internal use only. May be renamed or removed in a future release.
See Also:
  • Constructor Details

    • FlashClassAction

      public FlashClassAction(Component target, String className)
      Creates an action that flashes the given literal CSS class on target when the trigger fires.
      Parameters:
      target - the component whose root element to flash on, not null
      className - the CSS class name to flash, not null
    • FlashClassAction

      public FlashClassAction(Component target, Action.Input<? extends String> source)
      Creates an action that flashes the CSS class produced by source on target when the trigger fires.
      Parameters:
      target - the component whose root element to flash on, not null
      source - input that produces the CSS class name on the client when the trigger fires, not null
  • Method Details

    • toJs

      protected JsFunction toJs(Trigger trigger)
      Description copied from class: Action
      Builds the JsFunction that runs this action when the surrounding trigger fires. The returned function takes one runtime argument named event (declared by the framework when it composes the trigger handler); subclasses do not declare argument names themselves.

      The body is one statement. To embed a value produced on the client, capture an Action.Input's JsFunction as a capture and invoke it inside the body as $N(event).

      Specified by:
      toJs in class Action
      Parameters:
      trigger - the surrounding trigger this render is for, not null
      Returns:
      the action's JS function, not null