Magnetic Effect (snapEagerness: 3.0)

Configuration: { snapEagerness: 3.0 }

This creates an intentional "magnetic" attraction to the top edge - the snapping becomes a deliberate design feature rather than just gap prevention.

๐Ÿงฒ Magnetic snapping: The header "reaches" for the top edge with obvious eagerness. This becomes part of your interface's personality.

๐ŸŽฏ When Magnetic Behavior Makes Sense

Use snapEagerness: 3.0 when snapping should be a visible, intentional part of the user experience:

๐Ÿ”ฌ Three-Step Prediction Algorithm

The magnetic effect predicts three scroll frames ahead:

const handleScroll = () => {
  const currentScrollY = window.scrollY;
  const elementRect = element.getBoundingClientRect();
  
  // Calculate current scroll velocity
  const scrollVelocity = currentScrollY - lastScrollY;
  
  // Predict THREE scroll steps ahead - creates the magnetic effect
  const predictedTop = elementRect.top - 3.0 * scrollVelocity;
  //                                      โ†‘
  //                        snapEagerness: 3.0 = predict 3 steps ahead
  
  // Switch to sticky very early - creates the "magnetic" attraction
  if (mode === 'relative' && predictedTop >= 0) {
    mode = 'sticky';
    element.style.position = 'sticky';
    element.style.top = '0';
  }
}

๐Ÿงฒ Understanding the Magnetic Effect

What makes this feel "magnetic":

๐ŸŽฎ Gaming and Interactive Applications

The magnetic effect fits well in certain contexts:

Design philosophy: Sometimes "natural" isn't the goal. The magnetic effect makes the interface feel intentionally smart and responsive.

๐Ÿงช Testing the Magnetic Behavior

Experience the full magnetic effect with these tests:

โšก When NOT to Use Magnetic Snapping

Avoid 3.0+ values when:

๐ŸŽจ Design Integration

Making magnetic snapping work with your design:

๐Ÿ“Š Comparison with Other Values

The full snapEagerness spectrum:

๐Ÿ”ง Fine-tuning Beyond 3.0

You can go even higher:

Remember: High snapEagerness values should be a conscious design choice, not a default. Make sure it fits your interface personality.

Continue scrolling to experience the full magnetic effect. Notice how the header seems to have its own agenda - it's not just following your scroll, it's actively trying to snap into position. This creates a very different feel from natural movement.

The magnetic effect works best when users understand it's intentional - when the eager snapping becomes part of your app's character rather than feeling like a bug or glitch.

๐Ÿงฒ Magnetic Attraction in Full Effect! ๐Ÿงฒ
Feel how eagerly this header snaps to the top?
This is intentional interface personality.