MediaWiki:Gadget-toc-progress.js: различия между версиями

Нет описания правки
Нет описания правки
Строка 343: Строка 343:
var doc = document.documentElement;
var doc = document.documentElement;
var max = doc.scrollHeight - window.innerHeight;
var max = doc.scrollHeight - window.innerHeight;
var p = max > 0 ? Math.min( 1, Math.max( 0, window.scrollY / max ) ) : 0;
var p = max > 0 ? Math.min( 1, Math.max( 0, window.scrollY / max ) ) : 1;
pct.textContent = Math.round( p * 100 ) + '%';
pct.textContent = Math.round( p * 100 ) + '%';
ringFg.style.strokeDashoffset = RING_LEN * ( 1 - p );
ringFg.style.strokeDashoffset = RING_LEN * ( 1 - p );