Paper position

153 views
Skip to first unread message

WoodCarving Creations

unread,
Apr 15, 2021, 3:53:46 AM4/15/21
to JointJS
Hi All,

I'm struggling to find a way to know which is the paper position at the end of panning operation. What I need to achieve is:

1. Graph starts from a specific position (like 0,0)
2. The user grab paper and move the graph in another position using panning
3. Here is what i need to know, which are the current paper coordinates because when the user goes back it wants to open the graph in the same position and not again at 0,0

I think the right way is to use the scroll method, but I was not able to find the right coordinates to provide.

Thank you for the help

Roman Bruckner

unread,
Apr 15, 2021, 5:32:51 AM4/15/21
to joi...@googlegroups.com
Hi,

I assume you use ui.PaperScroller for panning.

// save position and current zoom level
const zoom = paperScroller.zoom();
const center = paperScroller.getVisibleArea().center();

// load position and zoom to the original level
paperScroller.zoom(zoom, { absolute: true });
paperScroller.center(center.x, center.y);

Best,
Roman


--

---
You received this message because you are subscribed to the Google Groups "JointJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jointjs+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jointjs/8b60400a-4154-4f6a-b141-5466ca159690n%40googlegroups.com.


--

WoodCarving Creations

unread,
Apr 15, 2021, 5:55:07 AM4/15/21
to JointJS

Thank you Roman, really appreciate your help, now it works perfectly.

Alexander Nestorov

unread,
Apr 24, 2021, 5:23:25 PM4/24/21
to JointJS
This can be used with the "blank:pointermove" event, but is there a way I can subscribe to the scrolling event (which also "moves" the paper) using the mouse wheel?

Regards!

Roman Bruckner

unread,
Apr 26, 2021, 9:11:16 AM4/26/21
to joi...@googlegroups.com
Hi Alex,

There is a `scroll` event triggered on the PaperScroller (https://resources.jointjs.com/docs/rappid/v3.3/ui.html#ui.PaperScroller.events).

paperScroller.on('scroll', function() {});

Which is an equivalent of

paperScroller.el.addEventListener('scroll', function() {}, false);

Best regards,
Roman

Reply all
Reply to author
Forward
0 new messages