utilities

Utility Functions

This page contains a summary of some common scenarios you may find when using jsPlumb, and what functions jsPlumb offers to help you.

Repainting an element or elements

Assuming you use jsPlumb.draggable to initialise your draggable elements, you do not typically need to instruct jsPlumb to repaint. However, there are times when you need to, for instance:

  • you have resized an element and you need jsPlumb to recompute the location of Endpoints on that element
  • you have moved an element programmatically
  • you didn’t actually use jsPlumb.draggable to initialise some draggable element.

To force a repaint, use:

jsPlumb.repaint(el, [ui])

The first argument - el - can be a number of different datatypes:

  • a string, representing the id of some element
  • a list of strings, representing the ids of some elements
  • a DOM element
  • a list of DOM elements
  • a selector from your underlying library
Performance: provide the element offset

Notice the ui argument? This is an offset in the form:

{ left:X, top:Y }

…which, if provided, means that jsPlumb does not have to go and compute the offset of the element.

Note this is of course relevant only if you are repainting a single element. If you provide this when you’re painting multiple elements, they will all be assumed to be at the given offset!

Repainting everything

To repaint everything:

jsPlumb.repaintEverything();

Element Ids

jsPlumb uses element ids as keys for Connections and Endpoints, so if an element id changes, jsPlumb needs to know about it. You can either have jsPlumb do it for you:

jsPlumb.setId(el, newId);

or tell jsPlumb about it afterwards:

jsPlumb.setIdChanged(oldId, newId);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值