You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've ran into a case where, when the query we pass to Torque doesn't return any row, the library throws the following error instead of not doing anything:
start must be smaller than end
In this case, the JSONP request returns the following properties:
and the AnimatorStepsRange throws the error on that line.
I've temporarily hidden the error by overriding the library with the following code, but I wonder if you could take a look at this to avoid throwing a misleading error:
/* We define the new AnimatorStepsRange to avoid the error message */constCustomAnimatorStepsRange=function(start,end){if(start<0)thrownewError('start must be a positive number');/* The only change is on the next line where ">=" has been replaced by ">" */if(start>end)thrownewError('start must be smaller than end');this.start=start;this.end=end;};CustomAnimatorStepsRange.prototype={diff: function(){returnthis.end-this.start;},isLast: function(step){return(step|0)===this.end;}};/* We create the layer */constlayer=newL.TorqueLayer({user: 'myUser',table: 'myTable',sql: 'myQueryWithNoResult',cartocss: 'myCartoCSS'});/* We override here two methods to use our custom AnimatorStepsRange */layer.animator.steps=function(_){this.options.steps=_;this._defaultStepsRange=newCustomAnimatorStepsRange(0,_);returnthis.rescale();};layer.animator.stepsRange=function(start,end){if(arguments.length===2){if(start<this._defaultStepsRange.start)thrownewError('start must be within default steps range');if(end>this._defaultStepsRange.end)thrownewError('end must be within default steps range');this._customStepsRange=newCustomAnimatorStepsRange(start,end);this.options.onStepsRange&&this.options.onStepsRange();varstep=this.step()|0;if(step<start||step>end){this.step(start);}}returnthis._customStepsRange||this._defaultStepsRange;};
Thanks,
Clément
The text was updated successfully, but these errors were encountered:
Hi guys!
I've ran into a case where, when the query we pass to Torque doesn't return any row, the library throws the following error instead of not doing anything:
In this case, the JSONP request returns the following properties:
and the
AnimatorStepsRange
throws the error on that line.I've temporarily hidden the error by overriding the library with the following code, but I wonder if you could take a look at this to avoid throwing a misleading error:
Thanks,
Clément
The text was updated successfully, but these errors were encountered: