Vis.js timeline onMoving throws an error

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Vis.js timeline onMoving throws an error



I am trying to get a callback for onMoving on my timeline but keep getting the error:



"(Error) : option onMoving must be a function onMoving(item, callback)"



This is what I am trying to do


options.onMoving = function (item, callback) console.log('onMoving');



For other things like snap this works without any problem


options.snap = function(date, scale, step)
var hour = snapTimeMinutes * 60 * 1000;
return Math.round(date / hour) * hour



How can I fix this error?



Other events I am not doing on the options object, but on the items like the following code, but this does not seem to work for onUpdating.


onUpdating


itemsJS.on('update', function (event, properties)
);



I cannot directly declare the options JSON since I am wrapping the code in GWT. And I cannot put functions inside an object...



Additional information:



What I am trying to achieve is using the onMoving callback from options. Like in this JS example : view-source:http://visjs.org/examples/timeline/editing/editingItemsCallbacks.html


onMoving



In my wrapper I created a Java Options object like.


public class Options

private boolean moveable = true;
private boolean showCurrentTime = false;
....



Then I create in java such an Options object and set the correct parameters.



Then in my wrapper I convert the Options object to a JSON string using GWTJackson.



And finally in a JSNI method I do the following :


var options = JSON.parse(optionsJson);

if (snapTimeMinutes != 0)
options.snap = function(date, scale, step) var hour = snapTimeMinutes * 60 * 1000; return Math.round(date / hour) * hour //I can still add parameters in the jsni method to the JS Options object, but if I try this with onMoving I get the error specified in the beginning of this post

timeline = new $wnd.vis.Timeline(container, itemsJS, groups, options);



This all works no problem with normal fields like boolean, string, int, float, ... But I don't know how I can add that onMoving thing, since it is a function.


onMoving





Why can't you declare the options JS object in GWT? JsInterop makes that easy, and even pre-JsInterop you can do that with JSOs (though it is a bit ugly).
– Colin Alworth
May 3 at 12:01





Well... Maybe GWT can do it. But I can't figure out how. Never used JsInterop, and I did not found a solution with JSNI. Any pointers on where to look of how to let it work with JSNI ?
– Knarf
May 3 at 14:17





Change the question to document the options format you need and the JS you'd ideally like to have, and I'd be happy to provide an answer showing the equivalent Java that GWT will compile to that JS.
– Colin Alworth
May 3 at 17:30





Added some extra information to the question
– Knarf
May 7 at 10:49




1 Answer
1



Try adding


selectable: true,
editable:
updateTime: true,
,



to your options.



The documentation says onMoving is
Only applicable when both options selectable and editable.updateTime or editable.updateGroup are set true


onMoving






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS