You have the ability to use a prior activity you’ve generated on another section of your site. This is beneficial when dealing with a repetitive layout or components with identical structure where you wish to employ the same activities.
There are 2 primary controls within Webflow’s activities to assist in the reutilization of activities:
- Trigger configurations—at this point, you can opt if the trigger solely pertains to a particular element (the chosen element), or all elements with the same classification
- Action targets — in this case, you can determine if actions in animations affect a specific element, a group of elements, or the interaction trigger itself
Important: At present, it is not feasible to recycle page activities. You’ll be required to assign page triggers to each of your pages. Nevertheless, you can allocate the animations to target the classification of an element so you can recycle them on each page. To do this, establish the page trigger(s) on the first page and forge your animation(s). Ensure you target the classification and not the chosen element. Subsequently, navigate to each page, introduce the page trigger(s) and designate the animation(s) you’ve previously formulated.
In this tutorial, we’ll guide you through 2 reusable animations:
- How to formulate a button arrow shift activity
- How to create a scroll within view activity
How to develop a button arrow shift activity
In this instance, you’ll comprehend how to initiate the same “arrow move out” activity on all buttons with the identical classification. You’ll also discover how to ensure that the animation solely influences the button arrow a site visitor is presently hovering on.
How to produce a custom button
To kick off, you’ll firstly craft a custom button that incorporates text and an arrow (i.e., what you’ll apply the animation on subsequently). You’ll need to upload an arrow image to the Assets panel to use in your button. To shape the custom button:
- Head to Insert panel > Basic
- Drop a link block onto the Webflow canvas
- Navigate to Style panel > Style selector and assign a classification to the link block (e.g., “Button box)
- Go to Insert panel > Typography
- Add a text block within the link block
- Proceed to Style panel > Style selector and assign a classification to the text block (e.g., “Button text”)
- Access the Assets panel
- Drag your arrow image into the link block
- Navigate to Style panel > Style selector and assign a classification to the arrow image (e.g., “Button arrow”)
- Choose the link block (i.e., the “Button box”)
- Head to Style panel > Layout and set Display to Flexbox
Now you’ve designed your button! You can include margin and padding, borders, a hover state, or any other styles. You can also duplicate the button for subsequent tests to confirm that your activity is applied to all buttons.
Expert advice: Assigning classifications to the custom button’s components (i.e., the link block, text block, and arrow image) enable you to reuse activities on other elements that possess the same classification. This is beneficial if you wish to recycle the custom button and have the same activity employed, for instance.
How to develop the custom button activity
Now, you can establish the button arrow shift activity, so the arrow shifts to the right when a site visitor hovers over the button. To construct the activity, you’ll:
- Craft the custom button activity trigger
- Establish the animation to shift the button’s arrow upon hover
- Establish the animation to reset the arrow’s positioning when hovering out
- Apply the trigger to all elements with the same classification
- Evaluate the custom button
Craft the custom button activity trigger
The trigger is what institutes the animation when a site visitor interacts with the button. In this scenario, you’ll set a mouse hover trigger, so when a site visitor hovers over the button, the animation (i.e., the arrow movement) transpires.
- Choose the link block (e.g., the “Button box”)
- Access the Activities panel
- Tap the “plus” icon adjacent to Element trigger
- Select “Mouse hover”
Establish the animation to shift the button’s arrow upon hover
In this step, you’ll arrange the hover animation on the button’s arrow, so it moves slightly right when a site visitor hovers over the button.
- Choose the link box (i.e., “Button box”)
- Tap “Select an animation” adjacent to Action in the On hover section
- Choose “Start an animation” under Custom animation
- Tap the “plus” icon next to Timed animations
- Specify a name for your animation (e.g., “Arrow move out”)
- Select the button’s arrow (i.e., the “Button arrow”)
- Tap the “plus” next to Actions
- Choose Move under Transform
- Set a pixel value on the x-axis (e.g., 6 px) under Move
- Adjust the easing and duration, if desired
- Select “Only children with this classification” next to Class
- Tap Save
Important: “Only children with this classification” is applied in reference to the trigger element (i.e., the “Button box” link block) and its children with that classification applied (i.e., the “Button arrow” arrow). If you don’t confine the animation to impact “only children,” every instance of the arrow on your site would shift when a site visitor hovers over one of the custom buttons.
Given that you’ve set the trigger based on the link block’s classification (i.e., “Button box”) and set the animation to impact only children with the arrow’s classification (i.e., “Button arrow), the activity will impact every instance of the custom button on your site — as long as the custom button encompasses both the “Button box” classification and the “Button arrow” classification.
Establish the animation to reset the arrow’s positioning on hover out
At this point, let’s configure the hover.During the hover-out transition of the button, implement an animation on the arrow to return it to its original position when the site visitor moves the cursor away from the button.
- Choose the link block (e.g., “Button box”)
- Navigate to the Interactions panel
- Select the trigger element as Mouse hover
- Click on “Select an animation” adjacent to Action in the On hover out section
- Opt for “Start an animation” under Custom animation
- Select the icon of “three disclosure dots” close to the existing animation (e.g., “Arrow move out”)
- Pick Duplicate
- Select the “cog” icon near the duplicated animation
- Alter the animation’s name (e.g., “Arrow move back”)
- Choose the movement animation of the arrow on the timeline
- Adjust the x-axis to 0px under Move
- Click Save
Extend the trigger to all elements sharing the same class
By default, the trigger only applies to the selected element (e.g., the link block), however, for a universal effect, modify the trigger to cover all elements with the same class (e.g., “Button box”), allowing the interaction to occur uniformly on all instances of that class. This approach enables duplication of the custom button across the website, ensuring uniform interaction on these duplicates as well.
To broaden the trigger to all elements with the same class:
- Pick the link block (i.e., the “Button box”)
- Access the Interactions panel
- Opt for the Mouse hover element trigger
- Choose Class in Trigger settings
The interaction will now encompass all elements sharing that class (i.e., “Button box”). Upon duplication of the custom button on the canvas, the duplicate button, inheriting the same classes, will exhibit the arrow move interaction identical to the original custom button.
Test the customized button
Verify the functionality of your site by hovering over your customized button, and any duplicates, to confirm that the interaction seamlessly applies to all buttons inheriting that class.
Creating a scroll activation interaction
While establishing a reusable scroll effect, it’s advantageous to target the trigger element itself. Here, we’ll demonstrate how to craft an interaction where a website heading slides to the right and increases opacity upon scrolling into view.
To develop this interaction, you will:
- Establish the scroll into view trigger
- Craft the scroll into view animation
- Specify the action targets
Establish the scroll into view trigger
To initiate the interaction, first, set a “Scroll into view” trigger on the parent element intended for animation (i.e., the div block).
- Pick the div block – for instance, assign a “Content wrapper” class to the div block
- Navigate to the Interactions panel
- Click on the “plus” icon alongside Element trigger
- Opt for “Scroll into view”
For reusing this interaction across elements with the same class, apply the trigger at the class level. Select Class under Trigger settings to ensure the animation activates whenever an element with that class (e.g., “Content wrapper”) scrolls into view.
Craft the scroll into view animation
The scroll into view animation encompasses 2 stages:
- Initial state — position the element 50px to the left and set opacity to 0%
- Scrolled into view state — transition the element to 100% opacity and return it to the x-axis origin
Commence by defining the initial state for the div block, placing it 50px to the left and at 0% opacity before it scrolls into view:
- Select the div block (e.g., “Content wrapper”)
- Access the Interactions panel
- Pick the Scroll into view element trigger
- Click on “Select an animation” adjacent to Action in the When scrolled into view section
- Choose “Start an animation” under Custom animation
- Select the “plus” icon near Timed animations
- Assign a name to your animation (e.g., “Content wrapper animation”)
- Click on the “plus” icon near Actions
- Opt for Move under Transform
- Specify a value for the x-axis (e.g., -50px) under Move
- Tick the “Set as initial state” checkbox under Timing
- Click on the “plus” icon near Actions
- Select Opacity under Style
- Set the Opacity to a value (e.g., 0%)
- Tick the “Set as initial state” checkbox under Timing
Next, define the actions once the heading scrolls into view:
- Click on the “plus” icon near Actions
- Opt for Move under Transform
- Specify a value for the x-axis (e.g., 0px) under Move
- Uncheck the “Set as initial state” checkbox under Timing
- Click on the “plus”icon on the timeline next to the action you just specified (e.g., the “Content wrapper” 0px Move action) — this will ensure that the action occurs simultaneously with the heading returning to 0px on the x-axis.
- Opt for Opacity within Style
- Specify a percentage value for Opacity (e.g., 100%)
- Press Save
Now, it is necessary to ensure that the animation solely impacts the element that triggers it (e.g., the “Content wrapper” div block).
Establish the action targets
To configure the action targets so that the actions influence the interaction trigger:
- Choose the div block (e.g., “Content wrapper”)
- Navigate to Interactions panel
- Pick the Scroll into view element trigger
- Press the “cog” beside the animation previously set (e.g., the “Content wrapper animation)
- Choose all actions in the animation timeline (hold Command (on Mac) or Control (on Windows) and click all timeline actions)
- Select “Interaction trigger” in the Affect dropdown
- Hit Save
By doing this, the actions will affect only the interaction trigger — rather than the specific element you initially chose when creating the animation. This approach allows for the reusability of the animation, replacing the previous target element(s) of the action with the trigger element of the new interaction.
- Include or eliminate Workspace spots and members - April 15, 2024
- Centering box summary - April 15, 2024
- Store a site for future reference - April 15, 2024