powerange
powerange copied to clipboard
Uncaught TypeError: Cannot read property 'offsetWidth' of undefined
Hi everyone!
When I tried to use the library, I got this error:
Uncaught TypeError: Cannot read property 'offsetWidth' of undefined
at new Horizontal (powerange.js:1602)
at new module.exports (powerange.js:1268)
Where does this come from? I just copied one of the examples in the example file:
<script>
var stp = document.querySelector('.js-step');
var initStp = new Powerange(stp, { start: 50, step: 10 });
</script>
<div class="slider-wrapper">
<input type="text" class="js-step" />
</div>
Thank you very much!
@TomFevrier I have the same error and I fixed it adding the script tag for import powerange.js before the the script tag for my Javascript function, like this:
<script src="assets/powerange-0.0.2.js"></script>
<script type="text/javascript">
var elem = document.querySelector('.js-opacity');
var init = new Powerange(elem, { callback: setOpacity, decimal: true, min: 0, max: 3, start: 1 });
function setOpacity() {
document.querySelector('.js-change-opacity').style.opacity = elem.value;
}
</script>
I hope can help you!