Dojo: how to use own onMove event (overwrite)

蹲街弑〆低调 提交于 2019-12-04 06:45:35

问题


In docs it was said that:

onMove(mover, leftTop, e) called during every move notification; should actually move the node; can be overwritten.

but no example how to overwrite it (onMove). Can somebody throw several lines of code to show how it works?

Thanks.


回答1:


You don't point out which dojo JavaScript class that the onMove function belongs to. However, you have a couple of generic ways to override functions that also applies in your case.

1) Create a new subclass using dojo.declare.

Suppose the JavaScript class name is myClass, you can use

dojo.declare('anotherClass', myClass, {
    onMove : function(mover, leftTop, e) {}   
});

2) Change the class's prototype using dojo.extend.

dojo.extend(myClass, {
    onMove : function(mover, leftTop, e) {}         
});

If you only want to override the function for a single instance, set the property directly.

var obj = new myClass();
obj.onMove = function() {};


来源:https://stackoverflow.com/questions/6508571/dojo-how-to-use-own-onmove-event-overwrite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!