1.1.1 • Published 7 years ago

fuckmyscroll v1.1.1

Weekly downloads
10
License
MIT
Repository
github
Last release
7 years ago

FuckMyScroll

Animated scrolling to certain point or anchor.

You can see a demo here.

Installing

Install via npm

$ npm install --save fuckmyscroll

Usage

In your script, create an instance of FuckMyScroll

const fms = new FuckMyScroll();
fms.init();

Working with anchors

Truly is not necessary be an anchor, but have href and fmscroll attributes.

<button href="#about" fmscroll>About</button>

<!-- Goes to -->
<article id="about">
  <!-- ... -->
</article>

Going to page points

Scroll by cordenates

let X = 0,
  Y = 1200;

fms.scrollTo(X, Y);

Options

const fms = new FuckMyScroll({
  speed: 14, // 14px/ms,
  init: () => {},
  end: () => {}
});
  • speed It is possible determine the speed, measured in pixels/milliseconds. Default is 7px/ms.
{
  speed: 20 // 20px/ms
}
  • init Callback executed on proccess initiation.
{
  init: () => { // ... }
}
  • end Callback executed on proccess finalization.
{
  end: () => { // ... }
}

Events

It is possible execute specific events for each anchors using fms-init and fms-end attributes with global functions:

<a href="#about" fmsscroll fms-init="prepareAbout" fms-end="showAbout">About</a>

<script>
/* Global scope */
function prepareAbout() {
    //...
}

function showAbout() { 
    // ...
}

window.onload = () => {
    // ...
}
</script>
1.1.1

7 years ago

1.1.0

7 years ago

1.0.4

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago