
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
use-magic-grid
Advanced tools
## Official React port of the [magic-grid](https://github.com/e-oj/Magic-Grid) library
Get Magic Grid via NPM:
npm install use-magic-grid
Import the useMagicGrid
hook:
import { useMagicGrid } from 'use-magic-grid';
or
const { useMagicGrid } = require('use-magic-grid');
You're good to go!
const magicGrid = useMagicGrid(...);
Note: You don't have to call magicGrid.listen
when using this hook
If your container doesn't have any dynamically loaded content i.e., all its child elements are always in the DOM, the items
property is not necessary. You should initialize the grid this way:
const magicGrid = useMagicGrid({
container: "#container", // Required. Can be a class, id, or an HTMLElement.
animate: true, // Optional.
});
If the container relies on data from an api, or experiences a delay, for whatever reason, before it can render its content in the DOM, you need to let the grid know the number of items to expect:
const magicGrid = useMagicGrid({
container: "#container", // Required. Can be a class, id, or an HTMLElement.
items: 20, // For a grid with 20 items. Required for dynamic content.
animate: true, // Optional.
});
Check the magic-grid docs for the full list of available functions
config (required): Configuration object
Initializes the grid with a configuration object, positions items and starts listening for changes to the container size.
const magicGrid = useMagicGrid({
container: "#container", // Required. Can be a class, id, or an HTMLElement
items: 30, // Optional. Number of items that should be present before initial positioning. Default: 1.
gutter: 30, // Optional. Space between items. Default: 25(px).
maxColumns: 5, // Optional. Maximum number of columns. Default: Infinite.
useMin: true, // Optional. Prioritize shorter columns when positioning items? Default: false.
useTransform: true, // Optional. Position items using CSS transform? Default: True.
animate: true, // Optional. Animate item positioning? Default: false.
center: true, //Optional. Center the grid items? Default: true.
});
This function is useful in cases where you have to manually trigger a repositioning; for instance, if a new element is added to the container.
const magicGrid = useMagicGrid({
container: "#container", // Required. Can be a class, id, or an HTMLElement
animate: true, // Optional
});
// get data from api
// append new element to DOM
// reposition items
magicGrid.positionItems();
FAQs
## Official React port of the [magic-grid](https://github.com/e-oj/Magic-Grid) library
The npm package use-magic-grid receives a total of 6 weekly downloads. As such, use-magic-grid popularity was classified as not popular.
We found that use-magic-grid demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.