Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to apply the zoom level to text size (keep the text appropriate size while zooming) #17

Open
arikan opened this issue Jan 7, 2013 · 9 comments

Comments

@arikan
Copy link

arikan commented Jan 7, 2013

Is there a method that we can get the zoom level from Viva.Graph or something. I need to use it so that text size stay appropriate while zooming in and out. Thanks.

@henry74
Copy link

henry74 commented Feb 16, 2013

Is there a way to turn off zooming?

@anvaka
Copy link
Owner

anvaka commented Feb 17, 2013

@arikan there is no build-in way to do this yet. The way I'm doing it in Amazon visualization is very cumbersome. I had to create a separate group layer g in the svg graphics root, and add all labels there. The I had to listen to rescaled events from the graphics class (Viva.Graph.Utils.events(graphics).on('rescaled' function(){...}) and use getTransformToElement()/getBBox() methods to update tooltip position.

I admit SVG support is purely designed part of the library. I putting myself a todo to make it better. Sorry about this.

@anvaka
Copy link
Owner

anvaka commented Feb 17, 2013

@henry74 there is no way to do this, if you are using renderer. I'm trying to understand your use case better. Do you need other interactive features of the renderer (e.g. panning, unified support of multiple graphics objects, graph change monitoring)? Or do you want to produce layout once and use it as a static structure?

@henry74
Copy link

henry74 commented Feb 17, 2013

I found a simple work around. My use case was to just prevent zooming of the graph since it detracted from the user experience.

I just captured the mousewheel event for the parent svg tag and return false. No mouse accidental mouse scroll zooming :-)

@anvaka
Copy link
Owner

anvaka commented Feb 17, 2013

@henry74 very nice :)!

@arikan
Copy link
Author

arikan commented Mar 12, 2013

@henry74 I need to prevent the mouse wheel scroll as well, I tried many things, but no luck, can you share a snippet.

For example this does NOT work:

document.body.addEventListener('DOMMouseScroll', function(e){
        e.preventDefault();
    }, false);

@umdstu
Copy link

umdstu commented Apr 22, 2013

Related to this, would there a way to set a max/min zoom level? Max zoom being something like 'fit all to screen' level.

@joerodrig
Copy link

Old question, but I was able to prevent zooming and thought I'd share a snippet of my solution/workaround incase anyone has the same problem(solution in Coffeescript):

    renderer.run() # the SVG element is created when the renderer is run
    svgElement = renderer.getGraphics().getGraphicsRoot() # Temporary var containing SVG element
    $(svgElement.bind( 'mousewheel DOMMouseScroll', (e) ->
         if e.shiftKey isnt true       #Zoom only if shift key is being held down
            e.preventDefault()        # Prevent zooming
            return false
    ) 

@anvaka
Copy link
Owner

anvaka commented Jan 18, 2015

Thank you @joerodrig3!

A small note about renderer.run(). You mentioned that SVG element is created when the renderer is run. This was fixed in version v0.5.8, and now you can call getGraphicsRoot() from graphics object as soon as it is created, no need to execute renderer.run() beforehand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants