Home

Awesome

Distribute Layers for Framer

InstallationCode ExamplesFull documentation


This package helps you position multiple Framer layers with ease.

<img alt="It's a bit like the Distribute Elements buttons in Sketch, but for Framer" src="https://cloud.githubusercontent.com/assets/875708/15664809/19baf084-2707-11e6-9e92-293fe47cdcd0.jpg" width="430">

You can position layers in three ways:

sameDistancesameMargin spaced
The layers are positioned every nth pixel, regardless of their height. <img src="http://placehold.it/250x10/ffffff/ffffff"><img src="https://cloud.githubusercontent.com/assets/875708/15650429/c6f44cda-2678-11e6-8da0-dca69880a7d4.gif" width="250">The layers follow each other with a constant margin between them. <img src="http://placehold.it/250x10/ffffff/ffffff"><img src="https://cloud.githubusercontent.com/assets/875708/15650431/c71e34fa-2678-11e6-8a2a-52b03d965d82.gif" width="250">The layers fill upp the space. The spacing between them is equal. <img src="http://placehold.it/250x10/ffffff/ffffff"><img src="https://cloud.githubusercontent.com/assets/875708/15650430/c70e0b3e-2678-11e6-8a6e-5a7dd9f4a4fd.gif" width="250">

You ➡️ can ➡️ also ➡️ distribute ➡️ layers ➡️ horizontally.

Installation

<img alt="Screenshot from Framer Studio with code example from Distribute Layers" src="https://cloud.githubusercontent.com/assets/875708/15688329/c7a9a72c-2779-11e6-9ed3-e808ca369b6d.jpg" width="888">

Code examples

{ distributeLayers } = require "distributeLayers"

layers = []
layers[0] = new Layer
layers[1] = new Layer
layers[2] = new Layer

distributeLayers.sameDistance
	layers: layers
	distance: 250

Full documentation

There are three functions:

All functions accept one argument: an options object. The functions can be called with the following arguments:

NameTypeRequiredDescription
layersarrayyesAn array containing the layers you want to distribute.
directionstringnohorizontal or vertical. Defaults to vertical.
startOffsetintnoX/Y starting point for the first layer. X when direction is horizontal, Y when vertical.

➡️ distributeLayers.sameDistance()

In addition to the parameters above, distributeLayers.sameDistance() accepts these additional arguments:

NameTypeRequiredDescription
distanceintnoHow much space to add between each arguments. Defaults to 500.

See example project (Click “open” to view code in Framer Studio)

➡️ distributeLayers.sameMargin()

In addition to the parameters above, distributeLayers.sameMargin() accepts these additional parameters:

NameTypeRequiredDescription
marginintnoMargin between each arguments. Defaults to 10.

See example project (Click “open” to view code in Framer Studio)

➡️ distributeLayers.spaced()

In addition to the parameters above, distributeLayers.spaced() accepts these additional parameters:

NameTypeRequiredDescription
maxintnoThe max area within which the layers should be rendered. Defaults to 1000.

See example project (Click “open” to view code in Framer Studio)