For more information, questions, bug reporting or feature requests, checkout the project on GitHub.
For most applications, the following minimal HTML structure can be used.
<div class="pushin">
<div class="pushin-layer">layer 1</div>
<div class="pushin-layer">layer 2</div>
</div>
For ultimate flexibility, PushIn can be configured in a couple ways: through the JavaScript API, and/or through data-*
attributes within the HTML. When using both in combination, data attributes will take precedence.
Pass a configuration object into the contstructor, whether you are using pushInStart()
or new PushIn()
.
The example below demonstrates how you can configure PushIn using the JavaScript API.
var config = {
target: document.querySelector('#my-target'),
scene: {
breakpoints: [768, 1440, 1920],
inpoints: [200, 300],
},
layers: [
// Layer 1
{
inpoints: [100, 300],
outpoints: [300, 600],
speed: 25
},
// Layer 2...
],
};
// Method 1: Using global function
pushInStart(config);
// Method 2: Using class constructor
new PushIn(config);
Each component of the PushIn plugin has its own set of configurations, separated into modules below.
<div class="pushin">
Name | HTML Attribute | Type | Description | |
---|---|---|---|---|
debug | none | boolean | Enables a tool to display the current scroll position which can help with animation timing. Default: | |
selector | none | string | If you are using the global Note: If using the Default: | |
target | data-pushin-target | string | JavaScript selector used to attach PushIn to an element on the page. Default: | |
scrollTarget | data-pushin-scroll-target | string | JavaScript selector used to bind scroll events. Use the string "window" to bind scroll events to the Window object, regardless of which element is the target. Default: | |
mode | data-pushin-mode | string | Specify how PushIn layers should be displayed. Options:
Default: | |
autoStart | data-pushin-auto-start | string | Automatically begin animating the effect based on where the PushIn container is while scrolling. Options:
Default: | |
length | data-pushin-length | number | Alias for Default: |
<div class="pushin-scene">
Name | HTML Attribute | Type | Description | |
---|---|---|---|---|
breakpoints | data-pushin-breakpoints | array | Provide an array of numbers to configure appropriate responsive design breakpoints. If using the data attribute, use a comma-separated string. Default: | |
inpoints | data-pushin-from | number|array | A single number, or an array of numbers representing the screen position at which the scene should begin animating. Providing an array of numbers will set a different inpoint for each corresponding breakpoint, used for responsive design. If using the data attribute, provide a comma-separated string to represent an array. Default: | |
layerDepth | data-pushin-layer-depth | number | When an inpoint and outpoint are not provided for a layer, PushIn will use this number to calculate how long the layer should animate when scrolling. Default: |
<div class="pushin-composition">
Name | HTML Attribute | Type | Description | |
---|---|---|---|---|
ratio | data-pushin-ratio | array | Caution: Use sparingly! Changing this setting is not recommended. Set an aspect ratio for your scene to determine the width and height of each layer. The aspect ratio is represented as an array. Example: a 2:1 ratio can be represented as array: If using the data attribute, pass in a comma-separated string. Example: Default: |
<div class="pushin-layer">
Name | HTML Attribute | Type | Description | |
---|---|---|---|---|
inpoints | data-pushin-from | number|array | A single number, or an array of numbers representing the screen position at which the layer should start animating. Providing an array of numbers will set a different inpoint for each corresponding breakpoint, used for responsive design. If using the data attribute, provide a comma-separated string to represent an array. Default: | |
outpoints | data-pushin-to | string | A single number, or an array of numbers representing the screen position at which the layer should stop animating. Providing an array of numbers will set a different outpoint for each corresponding breakpoint, used for responsive design. If using the data attribute, provide a comma-separated string to represent an array. Default: | |
speed | data-pushin-speed | number | A number representing how fast or slow the layer should grow or shrink during scroll events. Default: | |
transitions | data-pushin-transitions | boolean | Whether to fade in or out when the layer is not active. Setting this to Note: By default, the first layer does not fade in, and the last layer does not fade out. Default: | |
transitionStart | data-pushin-transition-start | number | Duration of the fade-in effect after the layer becomes active (in pixels). Note: Use Default: | |
transitionEnd | data-pushin-transition-end | number | Duration of the fade-out effect before the layer becomes inactive (in pixels). Note: Use Default: |