@v17development
I discovered on my website the following:
choose to view any blog post... I scroll down and see the following error: in tag console
index.js:38 Uncaught TypeError: Cannot read properties of null (reading 'style')
at index.js:38:19
index.js:38 >>>> progressBar.style.width = value + '%';
/*
* This file is part of justoverclock/thread-read-time extension.
*
* Copyright (c) 2021 Marco Colia.
* https://flarum.it
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
import app from 'flarum/forum/app';
import { extend } from 'flarum/common/extend';
import PostStream from 'flarum/forum/components/PostStream';
import PostStreamScrubber from 'flarum/forum/components/PostStreamScrubber';
app.initializers.add('justoverclock/thread-read-time', () => {
extend(PostStreamScrubber.prototype, 'view', function (vdom) {
if (vdom.children && vdom.children.splice) {
const insert = (
<div class="contReadingTime">
<p class="readTime" id="readPerc"/>
<div id="progress-bar" className="progressBar" />
</div>
);
vdom.children.splice(0, 0, insert);
}
});
extend(PostStream.prototype, ['oncreate', 'onupdate'], function () {
const progressBar = document.querySelector('#progress-bar');
const section = document.querySelector('div#app');
const readTime = document.querySelector('#readPerc');
const getScrollValue = () => {
let distance = -section.getBoundingClientRect().top;
let progressWidth = (distance / (section.getBoundingClientRect().height - document.documentElement.clientHeight)) * 100;
let value = Math.min(Math.max(parseInt(progressWidth), 0), 100);
progressBar.style.width = value + '%';
readTime.innerText =
app.translator.trans('justoverclock-thread-read-time.forum.reading') + ' ' +
value + '%' + ' ' + app.translator.trans('justoverclock-thread-read-time.forum.ofThread');
};
window.addEventListener('scroll', getScrollValue);
});
});
My CHECK : const progressBar = document.querySelector('#progress-bar'); #progress-bar << check not found in html page
Error due to extension
extension/justoverclock-thread-read-time "composer require justoverclock/thread-read-time:"*"
"