Skip to content
This repository was archived by the owner on Jul 29, 2019. It is now read-only.

Conversation

wimrijnders
Copy link

The following code fragment:

step.start();
  if (step.getCurrent() < this.valueMin) {
    step.next();
}

Occurs every single time a StepNumber instance is used. This leads me to conclude that it should be part of the start() method. I've made its running optional, default is the original working.

this._current = this._start - this._start % this._step;

if (checkFirst) {
if (this.getCurrent() < this._start) {
Copy link
Member

@yotamberk yotamberk Oct 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this._start refer each time to the correct this.<coordinate>Min?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. If you follow the logic in the StepNumber c'tor:

  • this.setRange() is called
  • in setRange():
  this._start = start ? start : 0;

The only ways that the new value will not be set are:

  • if it's zero, but that is the default anyway
  • if it's undefined or null, but then the range is invalid
  • if it's perhaps a boolean or another non-numeric type, in which case it had no business being passed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...so unless the passed start value for some reason changes between the initialization of the StepNumber instance and the call to start() (which is not the case in the code), we are good.

@yotamberk yotamberk merged commit 11b9210 into visjs:develop Oct 18, 2016
@wimrijnders wimrijnders deleted the PR6 branch October 18, 2016 13:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants