Git Product home page Git Product logo

Comments (9)

henry74 avatar henry74 commented on May 22, 2024

Is there a way to turn off zooming?

from vivagraphjs.

anvaka avatar anvaka commented on May 22, 2024

@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.

from vivagraphjs.

anvaka avatar anvaka commented on May 22, 2024

@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?

from vivagraphjs.

henry74 avatar henry74 commented on May 22, 2024

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 :-)

from vivagraphjs.

anvaka avatar anvaka commented on May 22, 2024

@henry74 very nice :)!

from vivagraphjs.

arikan avatar arikan commented on May 22, 2024

@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);

from vivagraphjs.

umdstu avatar umdstu commented on May 22, 2024

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

from vivagraphjs.

joerodrig avatar joerodrig commented on May 22, 2024

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
    ) 

from vivagraphjs.

anvaka avatar anvaka commented on May 22, 2024

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.

from vivagraphjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.