All Projects → bluwy → svelte-fast-dimension

bluwy / svelte-fast-dimension

Licence: MIT License
Fast dimension bindings using ResizeObservers

Programming Languages

javascript
184084 projects - #8 most used programming language
Svelte
593 projects
typescript
32286 projects
HTML
75241 projects
shell
77523 projects

Projects that are alternatives of or similar to svelte-fast-dimension

plugins
Elder.js plugins and community plugins.
Stars: ✭ 80 (+247.83%)
Mutual labels:  svelte
svelte-avatar
An avatar component for Svelte
Stars: ✭ 12 (-47.83%)
Mutual labels:  svelte
modern-fluid-typography-editor
Modern fluid typography editor
Stars: ✭ 222 (+865.22%)
Mutual labels:  svelte
mmss-client
No description or website provided.
Stars: ✭ 16 (-30.43%)
Mutual labels:  svelte
svelte-starter-kit
Svelte with brilliant bells and useful whistles
Stars: ✭ 384 (+1569.57%)
Mutual labels:  svelte
todomvc-svelte
TodoMVC built with Svelte and Store
Stars: ✭ 34 (+47.83%)
Mutual labels:  svelte
svelte-bricks
Naive Svelte Masonry component without column balancing (ragged columns at the bottom)
Stars: ✭ 22 (-4.35%)
Mutual labels:  svelte
svelte-trivia
A Quiz app completely made using Svelte
Stars: ✭ 25 (+8.7%)
Mutual labels:  svelte
sveld
Generate TypeScript definitions for your Svelte components
Stars: ✭ 281 (+1121.74%)
Mutual labels:  svelte
svelte-pdf
svelte-pdf provides a component for rendering PDF documents using PDF.js
Stars: ✭ 102 (+343.48%)
Mutual labels:  svelte
mathesar
Web application providing an intuitive user experience to databases.
Stars: ✭ 95 (+313.04%)
Mutual labels:  svelte
svelte-fullcalendar
A Svelte component wrapper around FullCalendar
Stars: ✭ 123 (+434.78%)
Mutual labels:  svelte
safenetwork-gitportal
p2p git portal - a decentralised alternative to github
Stars: ✭ 12 (-47.83%)
Mutual labels:  svelte
SvelteScaling
Does Svelte scale?
Stars: ✭ 21 (-8.7%)
Mutual labels:  svelte
cv
My online CV using Svelte
Stars: ✭ 35 (+52.17%)
Mutual labels:  svelte
felt-mockup
retired mockup 💚 customizable community tools that feel good
Stars: ✭ 47 (+104.35%)
Mutual labels:  svelte
focus-svelte
focus lock for svelte
Stars: ✭ 18 (-21.74%)
Mutual labels:  svelte
sveltober
Cybernetically enhanced October applications
Stars: ✭ 19 (-17.39%)
Mutual labels:  svelte
svelte-meteor-data
Reactively track Meteor data inside Svelte components
Stars: ✭ 14 (-39.13%)
Mutual labels:  svelte
svelteit
Svelteit is a minimalistic UI/UX component library for Svelte and Sapper projects
Stars: ✭ 64 (+178.26%)
Mutual labels:  svelte

svelte-fast-dimension

npm version CI

Fast dimension bindings using ResizeObservers.

Why? Svelte currently uses an iframe technique to measure dimensions so it works in older browsers. However, creating multiple iframes has a big performance impact and sometimes quirkiness. If your target browsers support ResizeObserver, this can significantly improve dimension binding performance.

Installation

npm install --save-dev svelte-fast-dimension

Usage

// svelte.config.js
import { fastDimension } from 'svelte-fast-dimension';

export default {
	preprocess: [fastDimension()]
};

Use dimension bindings as usual, it will use ResizeObservers under-the-hood:

<script>
	let a, b, c, d;
</script>

<div
	bind:clientWidth="{a}"
	bind:clientHeight="{b}"
	bind:offsetWidth="{c}"
	bind:offsetHeight="{d}"
/>

Recipes

Using with svelte-preprocess

Due to how Svelte applies preprocessors, using this with svelte-preprocess needs a bit more work to make sure we run this preprocessor only after svelte-preprocess finishes. There's an RFC to make this process clearer soon.

At the meantime, you can try one of these libraries:

Vite

svelte-fast-dimension injects an import from svelte-fast-dimension/action when preprocessing. This won't be detected during Vite's prebundling phase, and will cause on-the-fly prebundling which slows startup time. To remedy this, add svelte-fast-dimension/action to optimizeDeps.include.

Packages

Package Changelog
svelte-fast-dimension Changelog

Development

  • pnpm i to install dependencies
  • pnpm dev to run development build
  • pnpm test to run tests
  • pnpm build to run build

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].