Openseadragon: Dynamically toggle navigator?

Created on 7 Apr 2016  路  4Comments  路  Source: openseadragon/openseadragon

I know this must be very basic, but what would be the syntax in a button onclick event to dynamically toggle the navigator?

    function toggleNav(){
        if (viewer.showNavigator){
            viewer.showNavigator = false;}
        else {viewer.showNavigator = true;}
    }

question

Most helpful comment

Another option is to change the visibility of the navigator:

            var viewer = OpenSeadragon({
                // debugMode: true,
                id: "contentDiv",
                prefixUrl: "../../build/openseadragon/images/",
                tileSources: "../data/testpattern.dzi",
                showNavigator: true
            });

            var navigatorShown = true;
            function toggleNavigator() {
                navigatorShown = !navigatorShown;
                viewer.navigator.element.style.display = navigatorShown ? 'block' : 'none';
            }

There is a small issue with that, the red rectangle indicating the current position of the viewport will sometimes be misplaced after a toggle.

All 4 comments

@bdrichards I don't think you can do that.
But you cand destroy and recreate a navigator on button click.

See OpenSeadragon.Navigator

Another option is to change the visibility of the navigator:

            var viewer = OpenSeadragon({
                // debugMode: true,
                id: "contentDiv",
                prefixUrl: "../../build/openseadragon/images/",
                tileSources: "../data/testpattern.dzi",
                showNavigator: true
            });

            var navigatorShown = true;
            function toggleNavigator() {
                navigatorShown = !navigatorShown;
                viewer.navigator.element.style.display = navigatorShown ? 'block' : 'none';
            }

There is a small issue with that, the red rectangle indicating the current position of the viewport will sometimes be misplaced after a toggle.

Thanks for the ideas to investigate.
Simply hiding the navigator could work; however, my motivation to have the ability to completely turn off the navigator in order to collect some performance stats. I need to check how much of a performance hit the Navigator imposes.....

This might be helpful (see the last comments for working code):
https://github.com/openseadragon/openseadragon/issues/713

Was this page helpful?
0 / 5 - 0 ratings