Skip to content

Instantly share code, notes, and snippets.

View tdurand's full-sized avatar

Thibault Durand tdurand

View GitHub Profile
import { Portal } from "@radix-ui/react-portal";
import clsx from "clsx";
import { useAtom } from "jotai";
import { atomWithMachine } from "jotai/xstate";
import { useRouter } from "next/router";
import { useEffect } from "react";
import { assign, createMachine } from "xstate";
import clamp from "lodash/clamp";
/*
* Needs a tile layer, something like (for Leaflet) ..
*
* var tl = L.tileLayer("content://com.pahasapatrails.m.tiles/{style}/{z}/{x}/{y}.png",
* { style: "XXX", minZoom: 9, maxZoom: 13, tms: true });
* map.addLayer(tl);
*
*
* Also needs a provider entry under the application tag in the Android
* Manifest, something like the following ..
@Warry
Warry / Article.md
Created December 11, 2012 00:11
How to make faster scroll effects?

How to make faster scroll effects?

  • Avoid too many reflows (the browser to recalculate everything)
  • Use advanced CSS3 for graphic card rendering
  • Precalculate sizes and positions

Beware of reflows

The reflow appens as many times as there are frames per seconds. It recalculate all positions that change in order to diplay them. Basically, when you scroll you execute a function where you move things between two reflows. But there are functions that triggers reflows such as jQuery offset, scroll... So there are two things to take care about when you dynamically change objects in javascript to avoid too many reflows: