Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot read property 'offsetWidth' of undefined #28

Open
TomFevrier opened this issue Apr 14, 2017 · 1 comment
Open

Comments

@TomFevrier
Copy link

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!

@macagua
Copy link

macagua commented Sep 2, 2017

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants