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

TypeError: Cannot read property 'getBoundingClientRect' of null #146

Open
darthzeran opened this issue Nov 7, 2019 · 4 comments
Open

TypeError: Cannot read property 'getBoundingClientRect' of null #146

darthzeran opened this issue Nov 7, 2019 · 4 comments

Comments

@darthzeran
Copy link

darthzeran commented Nov 7, 2019

I am still investigating whether or not my code caused this, but it seems that there is never a check to prevent node from being null

 var node = _this.slider;
      var coordinateStyle = constants.orientation[orientation].coordinate;
      var directionStyle = reverse ? constants.orientation[orientation].reverseDirection : constants.orientation[orientation].direction;
      var clientCoordinateStyle = 'client' + (0, _utils.capitalize)(coordinateStyle);
      var coordinate = !e.touches ? e[clientCoordinateStyle] : e.touches[0][clientCoordinateStyle];
      var direction = node.getBoundingClientRect()[directionStyle];

Is this expected behavior from rangeslider?

I have successfully recreated my error, as it only happens when my react component disappears (because it gets turned off and gets replaced). Is there a way I can prevent this error from happening?

@BarrBozzO
Copy link

Same issue for me. Any progress?

@darthzeran
Copy link
Author

i doubt it

@QuirkWebDevelopment
Copy link

I have the same issue and no resolution.

@QuirkWebDevelopment
Copy link

Per Darthzeran's observation, I tried adding a check and it indeed fixed the error for me.

Starting around line 194 in the _this.position function:

` if(_this.slider) {

    var node = _this.slider;
    var coordinateStyle = constants.orientation[orientation].coordinate;
    var directionStyle = reverse ? constants.orientation[orientation].reverseDirection : constants.orientation[orientation].direction;
    var clientCoordinateStyle = 'client' + (0, _utils.capitalize)(coordinateStyle);
    var coordinate = !e.touches ? e[clientCoordinateStyle] : e.touches[0][clientCoordinateStyle];
    var direction = node.getBoundingClientRect()[directionStyle];
    var pos = reverse ? direction - coordinate - grab : coordinate - direction - grab;
    var value = _this.getValueFromPosition(pos);

    return value;
  }`

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

3 participants