readremaining.js

How long you'll need to read an article

  • 所有者: Aerolab/readremaining.js
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

ReadRemaining.js

This jQuery plugin allows you to show the user how long it will take to read the article considering the speed in which the user is scrolling.

Check out the demo

Quick start

Load the readremaining.jquery.js or the minified version readremaining.jquery.min.js after jQuery.

<script src="js/readremaining.jquery.js"></script>

Include the css file or the styles into your main css.

<link rel="stylesheet" href="css/rr_light.css"/>

To speed up the loading, you can include the code of readremaining.jquery.js in your main js file instead.

Init ReadRemaining.js on the element that will be scrolled to read the article. Usually the body of the document.

$('body').readRemaining();

That's it.

Customizing ReadRemaining.js

You can customize the behavior of the gauge with these options:

$('body').readRemaining({
  showGaugeDelay   : 1000,           // Delay before showing the indicator.
  showGaugeOnStart : false,          // Show the gauge initially, even before the user scroll.
  timeFormat       : '%mm %ss left', // Will replace %m and %s with minutes and seconds.
  maxTimeToShow    : 20*60,          // Only show time if is lower than x minutes (multiplied to seconds).
  minTimeToShow    : 10,             // Only show time if is higher than x seconds (If it's less than 10 seconds... just read).
  gaugeContainer   : '',             // The element where the gauge will append. If left '', the container will be the same scrolling element.
  insertPosition   : 'prepend'       // 'append' or 'prepend' as required by style
  verboseMode      : false           // Enable the console logs. For testing only.
  gaugeWrapper     : '',             // Optional, the element that define the visible scope for the gauge. If left "", the gauge will be visible all along.
  topOffset        : 0,              // Distance between the top of the gaugeWrapper and the point where the gauge will start to appear. Some designs require this.
  bottomOffset     : 0               // Distance between bottom border where the box will appear and the bottom of the element.
});

Other methods

You can get the remaining time for reading an element with ReadRemaining.js applied with the 'getRemainingTime' method. e.g.:

var remainingMinutes = $('body').readRemaining('getRemainingTime', {timeFormat : '%m'});

Known Issues

ReadRemaining.js works much more precise when the content of the scrolling element is homogeneous. If the size of the text or complexity of images change in different parts of the scrolling element, then the accuracy will drop.

Plugins

主要指標

概覽
名稱與所有者Aerolab/readremaining.js
主編程語言JavaScript
編程語言CSS (語言數: 3)
平台
許可證MIT License
所有者活动
創建於2015-05-04 18:08:55
推送於2017-07-20 02:35:14
最后一次提交2017-07-19 23:34:08
發布數4
最新版本名稱1.0.1 (發布於 )
第一版名稱readremainingjs (發布於 )
用户参与
星數551
關注者數34
派生數46
提交數13
已啟用問題?
問題數5
打開的問題數0
拉請求數2
打開的拉請求數0
關閉的拉請求數0
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?