Jumper provides a simple integration with Jump.js, a small, modern, dependency-free smooth scrolling library.
Features
- Vanilla JS, no jQuery required.
- Uses requestAnimationFrame, natively performant.
- A`Jump to Top` or `Jump Anywhere` block which can be placed via block admin.
- Jump anywhere for extra configurable links, as seen at a single page website.
- A few basic sensible styling. Use your own CSS to position the block as needed.
Requirements
- Core block.module.
- Blazy,
No Blazy lazy load library is needed. However Blazy is required to reduce dups for jQuery replacement methods provided by Blazy separately.
- Jump library:
o Download Jump from https://github.com/callmecavs/jump.js
o Extract it as is, rename "jump.js-master" to "jump", so the assets are at:
/libraries/jump/dist/jump.min.js
Optional Requirements
If you need to support old browsers (IE9), include requestAnimationFrame polyfill yourself into your own custom libraries from any below:
- https://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
- https://gist.github.com/paulirish/1579671
Note: IE10+ supports rAF, no need to include it.
Installation
Install the module as usual:
Visit admin/modules, and enable the Jumper module.
More info can be found on:
http://drupal.org/documentation/install/modules-themes/modules-7
Usages
- Visit /admin/structure/block
Place the provided Jumper block into footer, or any relevant region.
- Adjust a few settings accordingly, including custom jump links.
Custom Usages
- Add a class `
jumper
` to any link / button element containing attributes [data-target]
, or [href]
with relevant target to scroll to, e.g.:
<a href="#main" class="jumper">Jump</a>
or
<a href="#" data-target="#main" class="jumper">Jump</a>
or
<button data-target="#main" class="jumper">Jump</button>
- Include the provided block via block admin, or load the `jumper/load` library
as needed accordingly.
- To position the Jumper block anywhere, use a simple CSS override, e.g.:
/** Position the Jumper block at the bottom left corner. */
.jumper.jumper--block {
left: 15px;
}
/** Or center it at the bottom of page. */
.jumper.jumper--block {
left: 50%;
right: auto;
-ms-transform: translateX(-50%) translateY(100%);
transform: translateX(-50%) translateY(100%);
}
.is-jumper-visible .jumper.jumper--block {
-ms-transform: translateX(-50%) translateY(0);
transform: translateX(-50%) translateY(0);
}
By default, Jumper block is positioned at the bottom right.
Stylings
The styling is very basic. Use your own icons and CSS to override defaults. Specific to the provided block, it has additional class `jumper--block
` with a particular styling for a single jumper block.
Related modules
- http://drupal.org/project/back_to_top
Differences: Jumper doesn't use jQuery, nor jQuery UI. It uses native requestAnimationFrame, core block for placement, and can be used to jump anywhere with configurable links for smooth scrolling. Persuading existing module to depend on Blazy is more likely out of question than creating a new one in the same direction as Blazy.
- https://www.drupal.org/sandbox/gausarts/lory
Lory module may need jumper.module for its optional feature:
arrowDown
.
Known Issues
The `jumper` namespace is because `jump` is already reserved by `jump` menu module for different purposes. However `jumper` is still based on original jump.js intended singleton. Why not `jumpjs`, or `jumpingjackflash`? Maybe, but the author said: "... naming it according to your preference".