Denise Mauldin
Denise Mauldin

Reputation: 5615

JointJS paper coordinates

I have a pan controller in my application that scrolls the paper. How can I get the coordinates of what is showing to see if an element is entirely on screen?

Upvotes: 1

Views: 1698

Answers (1)

vt.
vt.

Reputation: 1428

you need to know the coordinates (x, y, width, height) of the paper element. x, y could be the scrollLeft, scrollTop. width and height is the dimension of the element. Lets call this "client coordinates". Client coordinates are the same as jointJs graph coordinates in case there are no transformations on paper (e.g scale). Otherwise you need to do a conversion between client coordinates and graph coordinates.

Methods like paper.clientToLocalPoint(clientX, clientY) or paper.clientToLocalRect(clientX, clientY, width, height) can do the job.

Or, in the RappidJS you can simply call the getVisibleArea on the joint.ui.PaperScroller plugin

Upvotes: 3

Related Questions