Accessing paging state and triggering a "go to canvas"

191 views
Skip to first unread message

Rory McNicholl

unread,
Sep 24, 2015, 2:32:53 PM9/24/15
to Universal Viewer
Hello,

We would like to know one thing and do another.

We would like to know which paging mode the UV is in, one-up or two-up at any given time.

We would also like to trigger a canvas change "externally" (ie so we can go to a given canvas using the URL of the parent page).

We've been able to access the current canvasIndex thanks to onCanvasIndexChanged. I'm not how much functionality is available via the easyXDM interface, but I can't see a way of doing the above.

Any tips appreciated.

Thanks,

Rory

Edward Silverton

unread,
Sep 25, 2015, 7:37:38 AM9/25/15
to Universal Viewer
Hi,

The UV triggers events that can be listened for in the containing page.

If you check out examples.js:


this shows the events you can listen for with jQuery (sounds like you've found uv.onCanvasIndexChanged).

I think adding a 'uv.onSettingsChanged' event would make a lot of sense, which would pass a settings object containing the current paging mode.

When a single instance of the UV is hosted on a site it can access hash parameters in the containing page's url:


You can use the 'cv' param to 'deep link' to a particular canvas index. Although it sounds like you want to programmatically alter the current canvas index using easyXDM's postMessage().

An example of this is the lightbox feature:


This is triggering the full screen event so the UV opens in full screen mode:


Here's a list of all the UV base 'commands':


You'd want to be able to do something like:

    uv.triggerSocket('uv.onCanvasIndexChanged', 23);

Unfortunately there isn't currently a way to do that. embed.js just looks at all divs on a page with the class '.uv' and bootstraps a UV instance for each. It's designed to not "pollute" the global namespace.

I think perhaps a new 'uv.js' script is needed that allows you to do things like this:

    var myUV = new UV('#myDiv');
    myUV.doSomething()

This is a different use case to embedding the UV using the generated embed code and would permit more interesting interactions.

There is a definite need for this - I'll create an issue on github. I'll also create an issue for the onSettingsChanged event.

Edward Silverton

unread,
Sep 25, 2015, 7:47:24 AM9/25/15
to Universal Viewer

Rory McNicholl

unread,
Oct 7, 2015, 7:40:47 AM10/7/15
to Universal Viewer
Thanks Edward,

Those two features would be really useful for us and hopefully for lots of others besides.

I've subscribed to those issues and I look forward to hearing more.

Cheers,

Rory

Edward Silverton

unread,
Oct 16, 2015, 12:39:36 PM10/16/15
to Universal Viewer
Hi Rory,


If you look at:


open the dev tools console, then try switching paging mode in the UV settings panel, you should see a 'uv.onSettingsChanged' event being logged with an associated settings object.

This contains a 'pagingEnabled' boolean property.

All UV events are now being sent to the containing page. This is part of some work I'm doing to enable fine-grained Google Analytics tracking.

Hope this helps!

Ed
Reply all
Reply to author
Forward
0 new messages