Socket
Socket
Sign inDemoInstall

paroller.js

Package Overview
Dependencies
1
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    paroller.js

Parallax scrolling jQuery plugin


Version published
Weekly downloads
1.7K
increased by0.65%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 01 Oct 2020

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc