Skip to main content
Question

Change background when triggering an interactive component

  • September 24, 2022
  • 3 replies
  • 2017 views

olga911

Hi! I have a question about using interactive components and different screens on the prototype.

I created an interactive component (a switch toggle) and yay, it works but – I want the background to also change when the on/off switch is activated. Basically, what I want to achieve, is when the toggle is “off”, the screen is black. When the toggle is “on”, the screen then changes to white.

Is there a way to do that? Via adding some kind of an overlay maybe? Would appreciate an insight!

3 replies

tank666
  • 4863 replies
  • September 24, 2022

If you want to use interactive components for this, you need to place a background layer on each component variant. That is, in order to change the properties of an object when interacting with an interactive component, you need that object to be part of that interactive component.

You can also consider creating this behavior using the “Navigate to” action to navigate to another frame. Thus you will have:

  1. A frame with a white background;
  2. A frame with a black background.

Between these frames there will be an interaction with an “On click” trigger and a “Navigate to” action to navigate to a frame with a white/black background.


olga911
  • Author
  • 2 replies
  • September 24, 2022

Not sure what you mean by ‘place a background layer on each component variant’.

If a background screen is part of the interactive component, means the entire screen becomes a component?..

  1. Regarding your section, I considered that, but it’s not as smooth somehow.

tank666
  • 4863 replies
  • September 24, 2022

This means that you need to add a new layer (background) inside the variant in order to be able to change its properties through interaction. The width and height of this layer should match the screen size.
For example:

Switch (component set)
    Off (variant)
        Switch layers
        Black background layer (W and H match screen size)

    On (variant)
        Switch layers
        White background layer (W and H match screen size)

But that doesn’t mean your screen will become a component. You only need to create an entire screen component when you want to change not only the color of the background layer, but other objects as well.

I don’t quite understand what could be the snags with the navigation between frames are. This way is much simpler and better (for this case) than using interactive components.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings