1.4.7 • Published 4 years ago

paroller.js v1.4.7

Weekly downloads
795
License
MIT
Repository
github
Last release
4 years ago

paroller.js

npm
A lightweight jQuery plugin that enables parallax scrolling effect

  • You can use it on elements with background property or on any other element
  • While scrolling elements can move: vertical, horizontal
  • Manipulated through html data-* attributes or jQuery options
  • Mobile ready
  • Easy to use

DEMO: Demo, Example page, Example page

Install

Before closing </body> element include:

  1. jQuery
  2. jquery.paroller.js

npm

$ npm install paroller.js  

Yarn

$ yarn add paroller.js  

Bower

$ bower install paroller.js  

CDN

jsDelivr, unpkg, bundle.run

Use

//a) initialize paroller.js 
$('.my-paroller').paroller();  

//b) initialize paroller.js and set attributes 
$(".my-element").paroller({ factor: 0.5, factorXs: 0.2, factorSm: 0.3, type: 'foreground', direction: 'horizontal' });  
<!-- a) select element and set attributes --> 
<div class="my-paroller" 
    data-paroller-factor="0.4" 
    data-paroller-factor-xs="0.2" 
    data-paroller-factor-sm="0.3" 
    data-paroller-type="foreground" 
    data-paroller-direction="horizontal"
>

<!-- b) select element -->  
<div class="my-element"></div>  

npm and browserify

require('paroller.js');  

Options

data attributes

You can control parallax effect by data-paroller-* or jQuery values.

data-paroller-*jQueryvaluedefault value
data-paroller-factorfactornumber (+/-)0
data-paroller-factor-xsfactorXsnumber (+/-)0
data-paroller-factor-smfactorSmnumber (+/-)0
data-paroller-factor-mdfactorMdnumber (+/-)0
data-paroller-factor-lgfactorLgnumber (+/-)0
data-paroller-typetypebackground, foregroundbackground
data-paroller-directiondirectionvertical, horizontalvertical
data-paroller-transitiontransitionCSS transitiontransform 0.1s ease

data-paroller-factor

Sets speed and distance of element's parallax effect on scroll. Value can be positive (0.3) or negative (-0.3). Less means slower. Different sign (+/-) means different direction (up/down, left/right).

:warning: Since factor is multiplier it must be set for paroller.js to have parallax effect.

data-paroller-factor-*

Sets paroller factor for selected breakpoint.

data-paroller-factor-*jQuery optionwindow width breakpoint
Extra smalldata-paroller-factor-xsfactorXs<576px
Smalldata-paroller-factor-smfactorSm<=768px
Mediumdata-paroller-factor-mdfactorMd<=1024px
Largedata-paroller-factor-lgfactorLg<=1200px
Extra Largedata-paroller-factor-xlfactorxl<=1920px

data-paroller-transition

Only effects elements with paroller.js type set to foreground!

JavaScript

// initialize paroller.js and set attributes for selected elements  
$(".paroller, [data-paroller-factor]").paroller({  
  factor: 0.2,            // multiplier for scrolling speed and offset, +- values for direction control  
  factorLg: 0.4,          // multiplier for scrolling speed and offset if window width is less than 1200px, +- values for direction control  
  type: 'foreground',     // background, foreground  
  direction: 'horizontal', // vertical, horizontal  
  transition: 'translate 0.1s ease' // CSS transition, added on elements where type:'foreground' 
});  
Set factor breakpoints
// initialize paroller.js and set attributes for selected elements  
$(".paroller, [data-paroller-factor]").paroller({  
    factor: 0.3,        // +/-, if no other breakpoint factor is set this value is selected  
    factorXs: 0.1,      // factorXs, factorSm, factorMd, factorLg, factorXl      
    factorSm: 0.2,      // factorXs, factorSm, factorMd, factorLg, factorXl      
    factorMd: 0.3,      // factorXs, factorSm, factorMd, factorLg, factorXl      
    factorLg: 0.4,      // factorXs, factorSm, factorMd, factorLg, factorXl
    factorXl: 0.5       // factorXs, factorSm, factorMd, factorLg, factorXl
    type: 'foreground',     // background, foreground  
    direction: 'horizontal',// vertical, horizontal 
    transition: 'translate 0.1s ease' // CSS transition, added on elements where type:'foreground' 
});  

License


MIT

1.4.7

4 years ago

1.4.6

5 years ago

1.4.5

5 years ago

1.4.4

6 years ago

1.4.3

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

7 years ago