Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8647071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:58:25+00:00 2026-06-12T12:58:25+00:00

Is there a way one could zoom and pan on a canvas using KineticJS?

  • 0

Is there a way one could zoom and pan on a canvas using KineticJS? I found this library kineticjs-viewport, but just wondering if there is any other way of achieving this because this library seems to be using so many extra libraries and am not sure which ones are absolutely necessary to get the job done.

Alternatively, I am even open to the idea of drawing a rectangle around the region of interest and zooming into that one particular area. Any ideas on how to achieve this? A JSFiddle example would be awesome!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:58:27+00:00Added an answer on June 12, 2026 at 12:58 pm

    You can simply add .setDraggable("draggable") to a layer and you will be able to drag it as long as there is an object under the cursor. You could add a large, transparent rect to make everything draggable. The zoom can be achieved by setting the scale of the layer. In this example I’m controlling it though the mousewheel, but it’s simply a function where you pass the amount you want to zoom (positive to zoom in, negative to zoom out). Here is the code:

    var stage = new Kinetic.Stage({
        container: "canvas",
        width: 500,
        height: 500
    });
    
    var draggableLayer = new Kinetic.Layer();
    draggableLayer.setDraggable("draggable");
    
    //a large transparent background to make everything draggable
    var background = new Kinetic.Rect({
        x: -1000,
        y: -1000,
        width: 2000,
        height: 2000,
        fill: "#000000",
        opacity: 0
    });
    
    draggableLayer.add(background);
    
    
    //don't mind this, just to create fake elements
    var addCircle = function(x, y, r){
      draggableLayer.add(new Kinetic.Circle({
            x: x*700,
            y: y*700,
            radius: r*20,
            fill: "rgb("+ parseInt(255*r) +",0,0)"
        })
      );
    }
    
    var circles = 300
    while (circles) {
      addCircle(Math.random(),Math.random(), Math.random())
      circles--;
    }
    
    var zoom = function(e) {
      var zoomAmount = e.wheelDeltaY*0.001;
      draggableLayer.setScale(draggableLayer.getScale().x+zoomAmount)
      draggableLayer.draw();
    }
    
    document.addEventListener("mousewheel", zoom, false)
    
    stage.add(draggableLayer)
    

    http://jsfiddle.net/zAUYd/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just wondering if there's a way one could display the windows phone
Is there any way (implemented or just in theory) that one could detect JavaScript
Wanted to know if there was a way one could query shelveset details from
Is there a way to use one of this preview controls with UISplitViewController's detail
I wanted to know if there's any way by which one could restrict the
Is there any way that one could extract the information about UI elements (of
Is there a way one could avoid type erasure and get access to a
I was wondering if there was possibly a way where one could scan a
Is there a way to embed one silverlight application in another silverlight application? if
Is there a way to use one CASE statement and return 2 different values?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.