DEPRECATED. Please go to https://github.com/10up/component-library
View official documentation for this package
npm install @10up/reading-position --save
@import url("@10up/reading-position");
The styles can be imported into your existing codebase by using PostCSS imports, or by including the standalone CSS file in your project.
Create a new instance by supplying the selector to use for the reading-position and an object containing any necessary callback functions.
import ReadingPosition from '@10up/reading-position';
new ReadingPosition( '.reading-position', {
onCreate: function() {
console.log( 'onCreate callback' );
},
scrollStart: function( percentage ) {
console.log( 'scrollStart callback', percentage );
},
scrollEnd: function( percentage ) {
console.log( 'scrollEnd callback', percentage );
},
scrolling: function( percentage ) {
console.log( 'scrolling callback', percentage );
}
} );
Example implementations at: https://10up.github.io/component-reading-position/demo/index.html
Active: 10up is actively working on this, and we expect to continue work for the foreseeable future including keeping tested up to the most recent version of WordPress. Bug reports, feature requests, questions, and pull requests are welcome.
