Blog o programowaniu, błędach w kodzie, debugowaniu i refaktoryzacji

// Dev notes

function deploySafely()

if (isFriday()) {

console.warn(„Do not touch production.”);

return;

}

deploy();

}

Notatki programistki

Kod jest jak dowcip. Jeśli musisz go wyjaśniać, jest kiepski


Praktyczny kod

Pigułka wiedzy

Master scroll-margin for Perfect Scroll Positioning

scroll-margin lets you control where an element stops when it’s scrolled into view.

It is perfect for fixing content hidden behind sticky headers.

section {
  // Leaves 80px space above 
  // when scrolled into view
  scroll-margin-top: 80px;
}

Works with scrollIntoView() and anchor links (#id) for smooth, precise positioning.

Avoid transition: all

Don’t use transition: all – it tells the browser to animate every property change, which can hurt performance and cause unwanted effects.

.element {
    transition: all 0.3s ease;
}

Instead, specify only the properties you actually want to animate:

.element {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

Animate Smart: Use Transform and Opacity for Better Performance

Always animate properties that don’t trigger reflow or repaint – like transform, opacity, or filter.

Animating layout-related properties (e.g. width, margin, top, box-shadow) forces the browser to recalculate positions and redraw the page, making animations laggy.

Blog

Najnowsze posty

Kategoria

JavaScript

Kategoria

Narzędzia Front-end Developera

Kategoria

Linux

Kategoria

CSS