ajaxscroll
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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.

Package Sidebar

Install

npm i ajaxscroll

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

12.6 kB

Total Files

9

Last publish

Collaborators

  • tehlordvortex