To create a section with horizontal scrolling that is triggered by hover or swipe on Webflow, you can follow these steps:
1. Open your project in the Webflow Designer and navigate to the page where you want to add the section.
2. Create a new section by clicking the "+" button in the page structure or by using the shortcut "S" on your keyboard.
3. Set the width of the section to be larger than the viewport width to allow horizontal scrolling. For example, you can set the width to 200vw to make it double the width of the viewport.
4. Apply a custom class to the section by selecting it in the Designer and opening the Style panel on the right side of the screen.
5. In the Style panel, go to the "Overflow" section and change the "Overflow X" property to "Scroll". This will enable horizontal scrolling within the section.
6. Create your content inside the section. You can add div blocks, images, text, or any other elements you want to display horizontally.
7. To enable the horizontal scrolling only when the user hovers over the section, go to the "Interactions" panel and create a new interaction specific to the section.
8. In the interaction, choose a trigger for the hover event, such as "Hover In" or "Mouse Enter".
9. Add an action to the interaction by clicking the "+" button next to the trigger. Select the "Affect Different Element" option and choose the section element.
10. In the action, change the "Scroll" property to "Scroll Horizontal" and set the desired duration for the scrolling animation.
11. Save and preview your project to see the horizontal scrolling in action when you hover over the section.
To allow vertical scrolling to bypass the section, you need to prevent the scrolling event when the user is not interacting with the section. Follow these steps to achieve this:
1. Add a custom attribute to your section element by opening the Attributes panel in the Designer. Click the "+" button to add a new attribute and name it "data-scroll". Set the value to "no" initially.
2. Go back to the interactions panel and select the interaction you created for the section's hover event.
3. In the action for the hover trigger, add an additional action before the scrolling action.
4. Choose the "Set Attribute" action and select the section element as the target element.
5. Set the attribute name to "data-scroll" and the value to "yes".
6. Create a new interaction, this time for the "Page Load" or "Navbar Click" trigger, depending on your needs.
7. Add a new action to this interaction and choose the "Set Attribute" action.
8. Select the section element and set the attribute name to "data-scroll" with the value "no".
9. Save and preview your project. The section will now only enable horizontal scrolling when the user hovers over it or swipes on it, and vertical scrolling will bypass the section.
By following these steps, you can create a section in Webflow that enables horizontal scrolling only when the user interacts with it, while still allowing vertical scrolling to bypass the section if desired.