Comments (1)
The problem is that you're setting the pointer events as auto
in the .transparent_content
container. If any element that's over the canvas can catch the pointer events, the canvas will not be able to catch those events, therefore you'll not be able to drag the rect.
Here's the code for anyone who wants to check it without needing to download the .txt:
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/[email protected]/konva.min.js"></script>
<meta charset="utf-8" />
<title>Konva Rect Demo</title>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
background-color: #f0f0f0;
}
#container {
position: absolute;
width: 500px;
height: 500px;
margin-top: 100px;
}
.transparent_container {
position: absolute;
height: 600px;
width: 600px;
z-index: 3;
pointer-events: none;
overflow: auto;
background-color: transparent;
}
.transparent_container .transparent_content {
height: 100000px;
background-color: transparent;
width: 100%;
overflow: auto;
pointer-events: auto;
}
</style>
</head>
<body>
<div id="container"></div>
<div class="transparent_container">
<div class="transparent_content"></div>
</div>
<script>
var width = window.innerWidth;
var height = window.innerHeight;
var stage = new Konva.Stage({
container: "container",
width: width,
height: height,
});
var layer = new Konva.Layer();
var rect1 = new Konva.Rect({
x: 20,
y: 20,
width: 100,
height: 50,
fill: "green",
stroke: "black",
strokeWidth: 4,
draggable: true,
});
// add the shape to the layer
layer.add(rect1);
// add the layer to the stage
stage.add(layer);
</script>
</body>
</html>
from konva.
Related Issues (20)
- getClientRect() for custom shapes returns wrong IRect
- Event was not triggered HOT 3
- Change transformer rotation origin for rectangle HOT 1
- Rect absoluteScale incorrect when a negative X scale is applied, also affects transformer anchors HOT 1
- layers vs. groups performance HOT 7
- The konva.Arrow functionality does not work properly in Chrome version 122. HOT 4
- How to move and scale content of transformer proportionally HOT 2
- Compatibility issue with chrome 51 HOT 3
- Overlapping shape fill got "removed". Evenodd issue? HOT 3
- NextJS server-side Stage initialization error HOT 1
- pixelized free draw HOT 4
- Feature Request - Export to PPT and Word file HOT 1
- loading json problems HOT 1
- Clip on group not working with width: 0 and height: 0 HOT 1
- Cannot override shape.rotation() in on transform event
- Can you create a brush tool like this one https://github.com/acamposuribe/p5.brush?
- Container ignores canvas width HOT 1
- Transformer handle drag issue: losing control after dragging and clicking on stage HOT 15
- Rotating the object image using the rotate function HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from konva.