Lightweight jQuery Plugin For Reading Progress - readingTime

File Size: 22.4 KB
Views Total: 631
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Lightweight jQuery Plugin For Reading Progress - readingTime

An ultra-light jQuery plugin that display an estimated time and an auto-update progress bar to read some text.

See also:

How to use it:

1. Load jQuery library and the jQuery readingTime plugin at the end of the web page.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="jquery.readingTime.min.js"></script>

2. Add your article to the web page as follow.

<div class="container">
  <article class="copy">
  ...
  </article>
</div>

3. Call the plugin on the article container.

$(".container").readingTime();

4. Style the timer & progress bar.

.container {
  width: 85%;
  margin: 0 auto;
  position: relative;
  padding: 70px 0;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

.container:before {
  content: "";
  position: fixed;
  width: 100%;
  height: 100px;
  top: 0;
  left: 0;
  pointer-events: none;
  background-image: -moz-linear-gradient(top, #ffffff, rgba(255, 255, 255, 0));
  background-image: -o-linear-gradient(top, #ffffff, rgba(255, 255, 255, 0));
  background-image: -webkit-linear-gradient(top, #ffffff, rgba(255, 255, 255, 0));
  background-image: linear-gradient(to bottom, #ffffff, rgba(255, 255, 255, 0));
}

.container .left {
  position: fixed;
  width: 100%;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  bottom: 0;
  left: 0;
  padding: 20px;
  -moz-transition-duration: 350ms;
  -o-transition-duration: 350ms;
  -webkit-transition-duration: 350ms;
  transition-duration: 350ms;
}

.container .left.hide {
 filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); opacity: 0; }

.container .left .perc {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 4px;
  z-index: 5000;
  pointer-events: none;
  background-color: #b3b3b3;
}

.container .left .counter {
  position: relative;
  font-size: 1.1em;
  z-index: 5;
  color: #666666;
}

.container .left:after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 150px;
  pointer-events: none;
  background-image: -moz-linear-gradient(top, rgba(255, 255, 255, 0), #ffffff);
  background-image: -o-linear-gradient(top, rgba(255, 255, 255, 0), #ffffff);
  background-image: -webkit-linear-gradient(top, rgba(255, 255, 255, 0), #ffffff);
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0), #ffffff);
}

5. Available options.

$(".container").readingTime({

// Words Per Minute
wpm: 300,

// Element that contains Copy
copyEl: '.copy',

// Element (will be generated) that is the parent container to the progress bar and remaining text label
remainingEl: '.left',

// Element that holds the text for how much time is left to finish reading the page.
counterEl: '.counter',

// Element that creates the progress bar
percEl: '.perc'

});

This awesome jQuery plugin is developed by jonstuebe. For more Advanced Usages, please check the demo page or visit the official website.