Home

Awesome

multiScroll.js

preview compatibility


multiScroll.js version PayPal Donate    |   3.7Kb gziped   |   Created by @imac2


A simple plugin to create multi scrolling websites with two vertical scrolling panels.

Invite me to a coffee Donate

Customizations of the plugin available upon request for some reasonable price. <a href="https://alvarotrigo.com/#contact-page">Contact me</a>.

Introduction

This plugin its in Beta version. Suggestion are more than welcome, not only for feature requests but also for coding style improvements.

Compatibility

multiScroll.js is fully functional on all modern browsers, as well as some old ones such as Internet Explorer 8, 9, Opera 12... It works with browsers with CSS3 support and with the ones who don't have it, making it ideal for old browsers compatibility. It is designed to work as well on touch devices such as mobile phones or tablets.

License

Commercial license

If you want to use multiScroll.js to develop commercial websites, themes, projects, and applications, the Commercial license is the appropriate license. With this option, your source code is kept proprietary. Which means, you won't have to change your whole application source code to an open source license. [Purchase a multiScroll.js Commercial License]

Non commercial license

If you are creating non commercial pages, you can use it without a license. Bare in mind all companies websites are considered commercial, ncluding non profit organisations websites.

The credit comments in the JavaScript and CSS files should be kept intact (even after combination or minification)

Read more about multiScroll's license.

Usage

As you can see in the example files, you will need to include the JavaScript file jquery.multiscroll.js (or the minified version jquery.multiscroll.min.js) and the css file jquery.multiscroll.css of the plugin, as well as jQuery. Optionally, you can add the jQuery UI library in case you want to use other easing effects apart from the ones included in the jQuery library which are the linear or swing effects. (easeInQuart is active by default, so you would need jQuery UI library or the customized version which is included in the vendors folder under the name jquery.easings.min.js.)

Install using bower or npm

Optionally, you can install multiscroll.js with bower or npm if you prefer: Terminal:

// With bower
bower install multiscroll.js

// With npm
npm install multiscroll.js

Including files:

<link rel="stylesheet" type="text/css" href="jquery.multiscroll.css" />

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<!-- This following line is needed in case of using the multiScroll option css3:false and using a non default value for the option `easingcss3`. You can also add the full jQuery UI instead of this file if you prefer -->
<script src="vendors/jquery.easings.min.js"></script>

<script type="text/javascript" src="jquery.multiscroll.js"></script>

Optional use of CDN

If you prefer to use a CDN to load the needed files, multiscroll.js is in CDNJS and others:

Required HTML structure

Each section will be defined with a div containing the section class. The active section by default will be the first section, which is taken as the home page.

<div id="multiscroll">
	<div class="ms-left">
		<div class="ms-section">Some section</div>
		<div class="ms-section">Some section</div>
		<div class="ms-section">Some section</div>
	</div>
	<div class="ms-right">
		<div class="ms-section">Some section</div>
		<div class="ms-section">Some section</div>
		<div class="ms-section">Some section</div>
	</div>
</div>

If you want to define a different starting point rather than the first section, just add the class active to the section you want to show on load. This should be done for the ms-right and ms-left elements.

<div class="ms-section active">Some section</div>

Initialization

All you need to do is call the plugin inside a $(document).ready function:

$(document).ready(function() {
	$('#multiscroll').multiscroll();
});

A more complex initialization with all options set could look like this:

$(document).ready(function() {
	$('#multiscroll').multiscroll({
		verticalCentered : true,
		scrollingSpeed: 700,
		easing: 'easeInQuart',
		easingcss3: 'ease-out',
		menu: false,
		sectionsColor: [],
		navigation: false,
		navigationPosition: 'right',
		navigationColor: '#000',
		navigationTooltips: [],
		loopBottom: false,
		loopTop: false,
		css3: false,
		paddingTop: 0,
		paddingBottom: 0,
		normalScrollElements: null,
		scrollOverflow: false,
		scrollOverflowOptions: null,
		keyboardScrolling: true,
		touchSensitivity: 5,

		//responsive
		responsiveWidth: 0,
		responsiveHeight: 0,
		responsiveExpand: false,

		// Custom selectors
		sectionSelector: '.ms-section',
		leftSelector: '.ms-left',
		rightSelector: '.ms-right',

		//events
		onLeave: function(index, nextIndex, direction){},
		afterLoad: function(anchorLink, index){},
		afterRender: function(){},
		afterResize: function(){},
	});
});

Creating links to sections

If you are using multiscroll.js with anchor links for the sections (using the anchors option), then you will be able to use anchor links also to navigate directly to a certain section by using the URL.

You can do it by creating accessing to the URL by adding the anchor. For example: http://youriste.com/#secondSection.

Be careful! data-anchor tags can not have the same value as any ID element on the site (or NAME element for IE).

You can also use the menu option and make use of anchor links (#) as explained below in the options section.

State classes added by multiScroll.js

multiScroll.js adds multiple classes in different elements to keep a record of the status of the site:

Use extensions

multiscroll.js provides a set of extensions you can use to enhance its default features. All of them are listed as multiscroll.js options.

Extensions requires you to use the minified file jquery.multiscroll.extensions.min.js that is inside the dist folder instead of the usual multiscroll.js file (jquery.multiscroll.js or jquery.multiscroll.min.js).

Once you adquire the extension file, you will need to add it before multiscroll. For example, if I want to use the Continuos Horizontal extension, I would have include the extension file and then the extensions version of the multiscroll file.

<script type="text/javascript" src="multiscroll.responsiveExpand.min.js"></script>
<script type="text/javascript" src="jquery.multiscroll.extensions.min.js"></script>

An activation key and a license key will be required for each extension. See more details about it here.

Then you will be able to use and configure them as explained in options.

Options

$('#multiscroll').multiscroll({
    licenseKey: 'YOUR_KEY_HERE'
});
$('#multiscroll').multiscroll({
	sectionsColor: ['#f2f2f2', '#4BBFC3', '#7BAABE', 'whitesmoke', '#000'],
});
<ul id="myMenu">
	<li data-menuanchor="firstPage" class="active"><a href="#firstPage">First section</a></li>
	<li data-menuanchor="secondPage"><a href="#secondPage">Second section</a></li>
	<li data-menuanchor="thirdPage"><a href="#thirdPage">Third section</a></li>
	<li data-menuanchor="fourthPage"><a href="#fourthPage">Fourth section</a></li>
</ul>
$('#multiscroll').multiscroll({
	anchors: ['firstPage', 'secondPage', 'thirdPage', 'fourthPage', 'lastPage'],
	menu: '#myMenu'
});

Methods

moveSectionUp()

Scrolls one section up:

$.fn.multiscroll.moveSectionUp();

moveSectionDown()

Scrolls one section down:

$.fn.multiscroll.moveSectionDown();

moveTo(section)

Scrolls the page to the given section. The first section parameter can be the index of the section or its anchor link.

/*Scrolling to the section with the anchor link `firstSection` */
$.fn.multiscroll.moveTo('firstSection');

//Scrolling to the 3rd section in the site
$.fn.multiscroll.moveTo(3);

setMouseWheelScrolling

Adds or remove the possibility of scrolling through sections by using mouse wheel (which is active by default).

$.fn.multiscroll.setMouseWheelScrolling(false);

setKeyboardScrolling

Adds or remove the possibility of scrolling through sections by using the keyboard arrow keys (which is active by default).

$.fn.multiscroll.setKeyboardScrolling(false);

setScrollingSpeed

Defines the scrolling speed in milliseconds.

$.fn.multiscroll.setScrollingSpeed(700);

destroy

Destroy plugin's events.

$.fn.multiscroll.destroy();

build

Build plugin's events after destroy.

$.fn.multiscroll.build();

Callbacks

afterLoad (anchorLink, index)

Callback fired once the sections have been loaded, after the scrolling has ended. Parameters:

In case of not having anchorLinks defined in the plugin the index parameter would be the only one to use.

Example:

	$('#multiscroll').multiscroll({
		anchors: ['firstPage', 'secondPage', 'thirdPage', 'fourthPage', 'lastPage'],

		afterLoad: function(anchorLink, index){
			//using index
			if(index == '3'){
				alert("Section 3 ended loading");
			}

			//using anchorLink
			if(anchorLink == 'secondSection'){
				alert("Section 2 ended loading");
			}
		}
	});

onLeave (index, nextIndex, direction)

This callback is fired once the user leaves a section, in the transition to the new section.

Parameters:

Example:

	$('#multiscroll').multiscroll({
		onLeave: function(index, nextIndex, direction){
			//after leaving section 2
			if(index == '2' && direction =='down'){
				alert("Going to section 3!");
			}

			else if(index == '2' && direction == 'up'){
				alert("Going to section 1!");
			}
		}
	});

afterRender()

This callback is fired just after the structure of the page is generated. This is the callback you want to use to initialize other plugins or fire any code which requires the document to be ready (as this plugin modifies the DOM to create the resulting structure).

Example:

	$('#multiscroll').multiscroll({
		afterRender: function(){
			alert("The resulting DOM structure is ready");
		}
	});

afterResize()

This callback is fired after resizing the browser's window. Just after the sections are resized.

Example:

	$('#multiscroll').multiscroll({
		afterResize: function(){
			alert("The sections have finished resizing");
		}
	});

Reporting issues

  1. Please, look for your issue before asking using the github issues search.
  2. Make sure you use the latest multiscroll.js version. No support is provided for older versions.
  3. Use the the Github Issues forum to create issues.
  4. An isolated reproduction of the issue will be required. Make use of jsfiddle or codepen for it if possible.

Changelog

To see the list of recent changes, see Releases section.

Build tasks

Want to build multiscroll.js distribution files? Please see Build Tasks

Resources

Related projects

Who is using multiscroll.js

If you want your page to be listed here. Please <a href="mailto:alvaro@alvarotrigo.com">contact me</a> with the URL.

Donations

Donations would be more than welcome :)

Donate