To create a sticky image portfolio section where the image changes as you scroll—like Deveb’s website—you'll need a combination of native Webflow interactions and custom JavaScript for browser compatibility and smooth performance.
1. Understand the Effect
- The layout typically has a sticky image on one side (left/right) that remains fixed within its container.
- On the other side, text blocks or sections scroll, each triggering the image to change.
- Safari-specific issues often involve
position: sticky
and transform
causing unexpected behavior.
2. Structure the Layout in Webflow
- Use a 2-column layout:
- Left Column: Sticky image container (set a fixed height and apply position: sticky with top: 0).
- Right Column: Vertical list of project sections (one for each portfolio item).
3. Webflow Interactions (for basic behavior)
- In Webflow Interactions:
- Add a scroll into view trigger on each content block in the right column.
- Use "Start an Animation" to change the background image in the sticky container each time.
- Limitations:
- Webflow’s default interactions don't natively support switching multiple images with smooth transitions or tracking scroll progress precisely.
4. Use JavaScript with Intersection Observer
- To enhance performance across all browsers (especially Safari), use Intersection Observer to track when each portfolio item enters the viewport.
- Sample logic:
- Define one shared sticky image container.
- For each content block, assign a data-image URL or ID.
- On intersection, update the image container’s background or image source.
5. Avoid Safari-Specific Issues
- In Safari, combining
transform: translateY()
on parent elements with position: sticky
often breaks layout. - Solution:
- Ensure the sticky container’s parent has no transforms applied.
- Avoid using
height: 100vh
as it may render inconsistently—use actual pixel values or CSS clamp(). - Test thoroughly with Safari’s Web Inspector in Responsive Design mode.
- Consider lightweight libraries:
- GSAP ScrollTrigger: Highly reliable and cross-browser. Allows triggering animations or image swaps tied directly to scroll position with smooth transitions.
- Locomotive Scroll: Adds smooth scrolling but may conflict with
position: sticky
, so use selectively. - Barba.js: For advanced transitions between pages but not required for this effect.
7. Optimization Tips
- Lazy-load images (use
loading="lazy"
) to avoid performance drops, especially on mobile. - Use WebP or AVIF formats to keep image sizes small.
- If using
background-image
, apply with CSS transitions for a smooth fade (opacity or fade-in effect).
Summary
To build a performant, cross-browser-compatible sticky image portfolio section in Webflow like Deveb’s design, combine Webflow’s layout tools with Intersection Observer or GSAP ScrollTrigger. Avoid relying solely on Webflow interactions for complex scroll-based behavior, and test specifically in Safari to resolve sticky positioning issues.