1.0.0 • Published 6 years ago

ajaxscroll v1.0.0

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

AJAXScroll

Scrolls the page to the element with id == location.hash after an AJAX request is made.

Installation

It's available on npm:

$ npm i --save ajaxscroll

Then in your code:

const AJAXScroll = require('ajaxscroll');
...
AJAXScroll.attach(xmlhttp);
...

You can also drop the JS file in your HTML page:

<script src="ajaxscroll.js"></script>
<script>
  ...
  AJAXScroll.attach(xmlhttp);
  ...
</script>

Documentation

AJAXScroll

attach(xmlhttp?: XMLHTTPRequest)

xmlhttp is optional. if it isn't provided, it'll hook into the XMLHTTPRequest prototype object.

This replaces XMLHTTPRequest.send with a custom version that scrolls once the request is complete.

detach(xmlhttp?: XMLHTTPRequest)

xmlhttp is optional. if it isn't provided, it'll hook into the XMLHTTPRequest prototype object.

This restores the default send function.