Konva - Change offset position after zoom and rotationHow do I effectively calculate zoom scale?Resizing Handles on a Rotated ElementKonva events mis-positioned after screen resizeChange element scale by scroll (zoom by scroll)Interactjs rotation shifts the positionKonva JS. Change Image position, rotateKonva: why are the offsets of the layer negative?Image width not correct after scalingKonva - stage centered on pinch zoomReact-konva Image position

Multi tool use
When do you stop "pushing" a book?
Was Mohammed the most popular first name for boys born in Berlin in 2018?
Why can't I prove summation identities without guessing?
What does formal training in a field mean?
Which other programming languages apart from Python and predecessor are out there using indentation to define code blocks?
Why use steam instead of just hot air?
Is there any evidence to support the claim that the United States was "suckered into WW1" by Zionists, made by Benjamin Freedman in his 1961 speech
How to select certain lines (n, n+4, n+8, n+12...) from the file?
Noob at soldering, can anyone explain why my circuit wont work?
How can I avoid subordinates and coworkers leaving work until the last minute, then having no time for revisions?
Passport stamps art, can it be done?
Is every story set in the future "science fiction"?
Is there a need for better software for writers?
Why do Thanos' punches not kill Captain America or at least cause some mortal injuries?
Why did they go to Dragonstone?
Improving Sati-Sampajañña (situative wisdom)
Windows OS quantum vs. SQL OS Quantum
Would encrypting a database protect against a compromised admin account?
Thesis' "Future Work" section – is it acceptable to omit personal involvement in a mentioned project?
Intersecting with the x-axis / intersecting the x-axis
Is it a good idea to copy a trader when investing?
date to display the EDT time
Series that evaluates to different values upon changing order of summation
Is BG 16.23 referring to Vedas or dharma śāstras?
Konva - Change offset position after zoom and rotation
How do I effectively calculate zoom scale?Resizing Handles on a Rotated ElementKonva events mis-positioned after screen resizeChange element scale by scroll (zoom by scroll)Interactjs rotation shifts the positionKonva JS. Change Image position, rotateKonva: why are the offsets of the layer negative?Image width not correct after scalingKonva - stage centered on pinch zoomReact-konva Image position
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm trying to implement a rotation and zoom feature with a slider. I need an image to always rotate from the center of the viewport. The main idea is changing the position and offset of the stage after drag event. Here's what I've tried
const width = window.innerWidth
const height = window.innerHeight
// scale is temp
let stage = new Konva.Stage(
container: 'canvas',
width,
height,
draggable: true,
offset:
x: width / 2,
y: height / 2
,
x: width / 2,
y: height / 2
)
let mapLayer = new Konva.Layer()
let imageObj = new Image()
imageObj.onload = function ()
let map = new Konva.Image(
image: imageObj,
prevX: 0,
prevY: 0
)
layer.add(map)
stage.add(mapLayer)
stage.on('dragstart', () =>
map.prevX = map.getAbsolutePosition().x
map.prevY = map.getAbsolutePosition().y
)
stage.on('dragend', () =>
let curX = map.getAbsolutePosition().x
let curY = map.getAbsolutePosition().y
let deltaX = Math.abs(map.prevX - curX)
let deltaY = Math.abs(map.prevY - curY)
if (curX > map.prevX)
stage.offsetX(stage.offsetX() - deltaX)
stage.x(stage.x() - deltaX)
else
stage.offsetX(stage.offsetX() + deltaX)
stage.x(stage.x() + deltaX)
if (curY > map.prevY)
stage.offsetY(stage.offsetY() - deltaY)
stage.y(stage.y() - deltaY)
else
stage.offsetY(stage.offsetY() + deltaY)
stage.y(stage.y() + deltaY)
stage.draw()
)
(if you want a full source code, clone it from here and run yarn run dev
from terminal, the app lives on localhost:3000
It works fine when the image is in the normal position (not zoomed and rotated yet) but after ANY kind of rotation or zooming, dragging the stage will cause the stage to be re-positioned in a weird fashion (the offset is still correct though). How can I set position and offset correctly?
javascript konvajs
add a comment |
I'm trying to implement a rotation and zoom feature with a slider. I need an image to always rotate from the center of the viewport. The main idea is changing the position and offset of the stage after drag event. Here's what I've tried
const width = window.innerWidth
const height = window.innerHeight
// scale is temp
let stage = new Konva.Stage(
container: 'canvas',
width,
height,
draggable: true,
offset:
x: width / 2,
y: height / 2
,
x: width / 2,
y: height / 2
)
let mapLayer = new Konva.Layer()
let imageObj = new Image()
imageObj.onload = function ()
let map = new Konva.Image(
image: imageObj,
prevX: 0,
prevY: 0
)
layer.add(map)
stage.add(mapLayer)
stage.on('dragstart', () =>
map.prevX = map.getAbsolutePosition().x
map.prevY = map.getAbsolutePosition().y
)
stage.on('dragend', () =>
let curX = map.getAbsolutePosition().x
let curY = map.getAbsolutePosition().y
let deltaX = Math.abs(map.prevX - curX)
let deltaY = Math.abs(map.prevY - curY)
if (curX > map.prevX)
stage.offsetX(stage.offsetX() - deltaX)
stage.x(stage.x() - deltaX)
else
stage.offsetX(stage.offsetX() + deltaX)
stage.x(stage.x() + deltaX)
if (curY > map.prevY)
stage.offsetY(stage.offsetY() - deltaY)
stage.y(stage.y() - deltaY)
else
stage.offsetY(stage.offsetY() + deltaY)
stage.y(stage.y() + deltaY)
stage.draw()
)
(if you want a full source code, clone it from here and run yarn run dev
from terminal, the app lives on localhost:3000
It works fine when the image is in the normal position (not zoomed and rotated yet) but after ANY kind of rotation or zooming, dragging the stage will cause the stage to be re-positioned in a weird fashion (the offset is still correct though). How can I set position and offset correctly?
javascript konvajs
To make it work properly in current state will require some trigonometry to fix dragging after rotation. What I'd suggest is to use different layers for different actions - parent window with width/height equal to container always rotateable with offset in the center and dragging/scaling nested element (withdraggable
option without any calculations). So in any dragged state the offset of the parent will be same in the same location, but it will show different part of the nested image.
– extempl
Mar 23 at 14:46
There may be some problems with scaling, though, as it also needs offset. I'd play with scaling on the same layer as rotation then.
– extempl
Mar 23 at 14:47
By parent window, do you mean the stage or a new layer?
– Cristopher Namchee
Mar 24 at 1:12
add a comment |
I'm trying to implement a rotation and zoom feature with a slider. I need an image to always rotate from the center of the viewport. The main idea is changing the position and offset of the stage after drag event. Here's what I've tried
const width = window.innerWidth
const height = window.innerHeight
// scale is temp
let stage = new Konva.Stage(
container: 'canvas',
width,
height,
draggable: true,
offset:
x: width / 2,
y: height / 2
,
x: width / 2,
y: height / 2
)
let mapLayer = new Konva.Layer()
let imageObj = new Image()
imageObj.onload = function ()
let map = new Konva.Image(
image: imageObj,
prevX: 0,
prevY: 0
)
layer.add(map)
stage.add(mapLayer)
stage.on('dragstart', () =>
map.prevX = map.getAbsolutePosition().x
map.prevY = map.getAbsolutePosition().y
)
stage.on('dragend', () =>
let curX = map.getAbsolutePosition().x
let curY = map.getAbsolutePosition().y
let deltaX = Math.abs(map.prevX - curX)
let deltaY = Math.abs(map.prevY - curY)
if (curX > map.prevX)
stage.offsetX(stage.offsetX() - deltaX)
stage.x(stage.x() - deltaX)
else
stage.offsetX(stage.offsetX() + deltaX)
stage.x(stage.x() + deltaX)
if (curY > map.prevY)
stage.offsetY(stage.offsetY() - deltaY)
stage.y(stage.y() - deltaY)
else
stage.offsetY(stage.offsetY() + deltaY)
stage.y(stage.y() + deltaY)
stage.draw()
)
(if you want a full source code, clone it from here and run yarn run dev
from terminal, the app lives on localhost:3000
It works fine when the image is in the normal position (not zoomed and rotated yet) but after ANY kind of rotation or zooming, dragging the stage will cause the stage to be re-positioned in a weird fashion (the offset is still correct though). How can I set position and offset correctly?
javascript konvajs
I'm trying to implement a rotation and zoom feature with a slider. I need an image to always rotate from the center of the viewport. The main idea is changing the position and offset of the stage after drag event. Here's what I've tried
const width = window.innerWidth
const height = window.innerHeight
// scale is temp
let stage = new Konva.Stage(
container: 'canvas',
width,
height,
draggable: true,
offset:
x: width / 2,
y: height / 2
,
x: width / 2,
y: height / 2
)
let mapLayer = new Konva.Layer()
let imageObj = new Image()
imageObj.onload = function ()
let map = new Konva.Image(
image: imageObj,
prevX: 0,
prevY: 0
)
layer.add(map)
stage.add(mapLayer)
stage.on('dragstart', () =>
map.prevX = map.getAbsolutePosition().x
map.prevY = map.getAbsolutePosition().y
)
stage.on('dragend', () =>
let curX = map.getAbsolutePosition().x
let curY = map.getAbsolutePosition().y
let deltaX = Math.abs(map.prevX - curX)
let deltaY = Math.abs(map.prevY - curY)
if (curX > map.prevX)
stage.offsetX(stage.offsetX() - deltaX)
stage.x(stage.x() - deltaX)
else
stage.offsetX(stage.offsetX() + deltaX)
stage.x(stage.x() + deltaX)
if (curY > map.prevY)
stage.offsetY(stage.offsetY() - deltaY)
stage.y(stage.y() - deltaY)
else
stage.offsetY(stage.offsetY() + deltaY)
stage.y(stage.y() + deltaY)
stage.draw()
)
(if you want a full source code, clone it from here and run yarn run dev
from terminal, the app lives on localhost:3000
It works fine when the image is in the normal position (not zoomed and rotated yet) but after ANY kind of rotation or zooming, dragging the stage will cause the stage to be re-positioned in a weird fashion (the offset is still correct though). How can I set position and offset correctly?
javascript konvajs
javascript konvajs
asked Mar 23 at 9:46


Cristopher NamcheeCristopher Namchee
31
31
To make it work properly in current state will require some trigonometry to fix dragging after rotation. What I'd suggest is to use different layers for different actions - parent window with width/height equal to container always rotateable with offset in the center and dragging/scaling nested element (withdraggable
option without any calculations). So in any dragged state the offset of the parent will be same in the same location, but it will show different part of the nested image.
– extempl
Mar 23 at 14:46
There may be some problems with scaling, though, as it also needs offset. I'd play with scaling on the same layer as rotation then.
– extempl
Mar 23 at 14:47
By parent window, do you mean the stage or a new layer?
– Cristopher Namchee
Mar 24 at 1:12
add a comment |
To make it work properly in current state will require some trigonometry to fix dragging after rotation. What I'd suggest is to use different layers for different actions - parent window with width/height equal to container always rotateable with offset in the center and dragging/scaling nested element (withdraggable
option without any calculations). So in any dragged state the offset of the parent will be same in the same location, but it will show different part of the nested image.
– extempl
Mar 23 at 14:46
There may be some problems with scaling, though, as it also needs offset. I'd play with scaling on the same layer as rotation then.
– extempl
Mar 23 at 14:47
By parent window, do you mean the stage or a new layer?
– Cristopher Namchee
Mar 24 at 1:12
To make it work properly in current state will require some trigonometry to fix dragging after rotation. What I'd suggest is to use different layers for different actions - parent window with width/height equal to container always rotateable with offset in the center and dragging/scaling nested element (with
draggable
option without any calculations). So in any dragged state the offset of the parent will be same in the same location, but it will show different part of the nested image.– extempl
Mar 23 at 14:46
To make it work properly in current state will require some trigonometry to fix dragging after rotation. What I'd suggest is to use different layers for different actions - parent window with width/height equal to container always rotateable with offset in the center and dragging/scaling nested element (with
draggable
option without any calculations). So in any dragged state the offset of the parent will be same in the same location, but it will show different part of the nested image.– extempl
Mar 23 at 14:46
There may be some problems with scaling, though, as it also needs offset. I'd play with scaling on the same layer as rotation then.
– extempl
Mar 23 at 14:47
There may be some problems with scaling, though, as it also needs offset. I'd play with scaling on the same layer as rotation then.
– extempl
Mar 23 at 14:47
By parent window, do you mean the stage or a new layer?
– Cristopher Namchee
Mar 24 at 1:12
By parent window, do you mean the stage or a new layer?
– Cristopher Namchee
Mar 24 at 1:12
add a comment |
1 Answer
1
active
oldest
votes
The solution to your initial issue below.
Note that I put a circle and a tooltip as well to a single layer to be able to drag them as a single one. Also, it should be added after map
to have binding work.
import Konva from 'konva'
import map from './../resources/unpar.svg'
const width = window.innerWidth
const height = window.innerHeight
// scale is temp
let stage = new Konva.Stage(
container: 'canvas',
width,
height,
offset:
x: width / 2,
y: height / 2
,
x: width / 2,
y: height / 2
)
let layer = new Konva.Layer(draggable: true)
let testCircle = new Konva.Circle(
x: 633,
y: 590,
radius: 10,
fill: 'white',
stroke: 'black'
)
testCircle.on('mousemove', function ()
tooltip.position(
x: testCircle.x() - 90,
y: testCircle.y() - 50
)
tooltip.text('Pintu Depan Gedung 10')
tooltip.show()
layer.batchDraw()
)
testCircle.on('mouseout', function ()
tooltip.hide()
layer.draw()
)
var tooltip = new Konva.Text(
text: '',
fontFamily: 'Calibri',
fontSize: 18,
padding: 5,
textFill: 'white',
fill: 'black',
alpha: 0.75,
visible: false
)
let imageObj = new Image()
imageObj.onload = function ()
const map = new Konva.Image(
image: imageObj,
)
layer.add(map)
layer.add(testCircle)
layer.add(tooltip)
stage.add(layer)
imageObj.src = map
export default stage
I know this works, but is it possible to do it without lumping all object on single layer?
– Cristopher Namchee
Mar 24 at 10:53
@CristopherNamchee Theoretically yes, but I am not sure how at the moment as it requires some research. If you could add one layer to another it would be quite simple, but there are a lot of restrictions of types which could include only certain types of containers/nodes.
– extempl
Mar 24 at 11:05
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312474%2fkonva-change-offset-position-after-zoom-and-rotation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The solution to your initial issue below.
Note that I put a circle and a tooltip as well to a single layer to be able to drag them as a single one. Also, it should be added after map
to have binding work.
import Konva from 'konva'
import map from './../resources/unpar.svg'
const width = window.innerWidth
const height = window.innerHeight
// scale is temp
let stage = new Konva.Stage(
container: 'canvas',
width,
height,
offset:
x: width / 2,
y: height / 2
,
x: width / 2,
y: height / 2
)
let layer = new Konva.Layer(draggable: true)
let testCircle = new Konva.Circle(
x: 633,
y: 590,
radius: 10,
fill: 'white',
stroke: 'black'
)
testCircle.on('mousemove', function ()
tooltip.position(
x: testCircle.x() - 90,
y: testCircle.y() - 50
)
tooltip.text('Pintu Depan Gedung 10')
tooltip.show()
layer.batchDraw()
)
testCircle.on('mouseout', function ()
tooltip.hide()
layer.draw()
)
var tooltip = new Konva.Text(
text: '',
fontFamily: 'Calibri',
fontSize: 18,
padding: 5,
textFill: 'white',
fill: 'black',
alpha: 0.75,
visible: false
)
let imageObj = new Image()
imageObj.onload = function ()
const map = new Konva.Image(
image: imageObj,
)
layer.add(map)
layer.add(testCircle)
layer.add(tooltip)
stage.add(layer)
imageObj.src = map
export default stage
I know this works, but is it possible to do it without lumping all object on single layer?
– Cristopher Namchee
Mar 24 at 10:53
@CristopherNamchee Theoretically yes, but I am not sure how at the moment as it requires some research. If you could add one layer to another it would be quite simple, but there are a lot of restrictions of types which could include only certain types of containers/nodes.
– extempl
Mar 24 at 11:05
add a comment |
The solution to your initial issue below.
Note that I put a circle and a tooltip as well to a single layer to be able to drag them as a single one. Also, it should be added after map
to have binding work.
import Konva from 'konva'
import map from './../resources/unpar.svg'
const width = window.innerWidth
const height = window.innerHeight
// scale is temp
let stage = new Konva.Stage(
container: 'canvas',
width,
height,
offset:
x: width / 2,
y: height / 2
,
x: width / 2,
y: height / 2
)
let layer = new Konva.Layer(draggable: true)
let testCircle = new Konva.Circle(
x: 633,
y: 590,
radius: 10,
fill: 'white',
stroke: 'black'
)
testCircle.on('mousemove', function ()
tooltip.position(
x: testCircle.x() - 90,
y: testCircle.y() - 50
)
tooltip.text('Pintu Depan Gedung 10')
tooltip.show()
layer.batchDraw()
)
testCircle.on('mouseout', function ()
tooltip.hide()
layer.draw()
)
var tooltip = new Konva.Text(
text: '',
fontFamily: 'Calibri',
fontSize: 18,
padding: 5,
textFill: 'white',
fill: 'black',
alpha: 0.75,
visible: false
)
let imageObj = new Image()
imageObj.onload = function ()
const map = new Konva.Image(
image: imageObj,
)
layer.add(map)
layer.add(testCircle)
layer.add(tooltip)
stage.add(layer)
imageObj.src = map
export default stage
I know this works, but is it possible to do it without lumping all object on single layer?
– Cristopher Namchee
Mar 24 at 10:53
@CristopherNamchee Theoretically yes, but I am not sure how at the moment as it requires some research. If you could add one layer to another it would be quite simple, but there are a lot of restrictions of types which could include only certain types of containers/nodes.
– extempl
Mar 24 at 11:05
add a comment |
The solution to your initial issue below.
Note that I put a circle and a tooltip as well to a single layer to be able to drag them as a single one. Also, it should be added after map
to have binding work.
import Konva from 'konva'
import map from './../resources/unpar.svg'
const width = window.innerWidth
const height = window.innerHeight
// scale is temp
let stage = new Konva.Stage(
container: 'canvas',
width,
height,
offset:
x: width / 2,
y: height / 2
,
x: width / 2,
y: height / 2
)
let layer = new Konva.Layer(draggable: true)
let testCircle = new Konva.Circle(
x: 633,
y: 590,
radius: 10,
fill: 'white',
stroke: 'black'
)
testCircle.on('mousemove', function ()
tooltip.position(
x: testCircle.x() - 90,
y: testCircle.y() - 50
)
tooltip.text('Pintu Depan Gedung 10')
tooltip.show()
layer.batchDraw()
)
testCircle.on('mouseout', function ()
tooltip.hide()
layer.draw()
)
var tooltip = new Konva.Text(
text: '',
fontFamily: 'Calibri',
fontSize: 18,
padding: 5,
textFill: 'white',
fill: 'black',
alpha: 0.75,
visible: false
)
let imageObj = new Image()
imageObj.onload = function ()
const map = new Konva.Image(
image: imageObj,
)
layer.add(map)
layer.add(testCircle)
layer.add(tooltip)
stage.add(layer)
imageObj.src = map
export default stage
The solution to your initial issue below.
Note that I put a circle and a tooltip as well to a single layer to be able to drag them as a single one. Also, it should be added after map
to have binding work.
import Konva from 'konva'
import map from './../resources/unpar.svg'
const width = window.innerWidth
const height = window.innerHeight
// scale is temp
let stage = new Konva.Stage(
container: 'canvas',
width,
height,
offset:
x: width / 2,
y: height / 2
,
x: width / 2,
y: height / 2
)
let layer = new Konva.Layer(draggable: true)
let testCircle = new Konva.Circle(
x: 633,
y: 590,
radius: 10,
fill: 'white',
stroke: 'black'
)
testCircle.on('mousemove', function ()
tooltip.position(
x: testCircle.x() - 90,
y: testCircle.y() - 50
)
tooltip.text('Pintu Depan Gedung 10')
tooltip.show()
layer.batchDraw()
)
testCircle.on('mouseout', function ()
tooltip.hide()
layer.draw()
)
var tooltip = new Konva.Text(
text: '',
fontFamily: 'Calibri',
fontSize: 18,
padding: 5,
textFill: 'white',
fill: 'black',
alpha: 0.75,
visible: false
)
let imageObj = new Image()
imageObj.onload = function ()
const map = new Konva.Image(
image: imageObj,
)
layer.add(map)
layer.add(testCircle)
layer.add(tooltip)
stage.add(layer)
imageObj.src = map
export default stage
edited Mar 24 at 6:14
answered Mar 24 at 6:05
extemplextempl
2,0951331
2,0951331
I know this works, but is it possible to do it without lumping all object on single layer?
– Cristopher Namchee
Mar 24 at 10:53
@CristopherNamchee Theoretically yes, but I am not sure how at the moment as it requires some research. If you could add one layer to another it would be quite simple, but there are a lot of restrictions of types which could include only certain types of containers/nodes.
– extempl
Mar 24 at 11:05
add a comment |
I know this works, but is it possible to do it without lumping all object on single layer?
– Cristopher Namchee
Mar 24 at 10:53
@CristopherNamchee Theoretically yes, but I am not sure how at the moment as it requires some research. If you could add one layer to another it would be quite simple, but there are a lot of restrictions of types which could include only certain types of containers/nodes.
– extempl
Mar 24 at 11:05
I know this works, but is it possible to do it without lumping all object on single layer?
– Cristopher Namchee
Mar 24 at 10:53
I know this works, but is it possible to do it without lumping all object on single layer?
– Cristopher Namchee
Mar 24 at 10:53
@CristopherNamchee Theoretically yes, but I am not sure how at the moment as it requires some research. If you could add one layer to another it would be quite simple, but there are a lot of restrictions of types which could include only certain types of containers/nodes.
– extempl
Mar 24 at 11:05
@CristopherNamchee Theoretically yes, but I am not sure how at the moment as it requires some research. If you could add one layer to another it would be quite simple, but there are a lot of restrictions of types which could include only certain types of containers/nodes.
– extempl
Mar 24 at 11:05
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312474%2fkonva-change-offset-position-after-zoom-and-rotation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
eY2jh w,KJE jQM gkqL8DtQKQn73T7wrRanjS0lskfxY8adR3f2e
To make it work properly in current state will require some trigonometry to fix dragging after rotation. What I'd suggest is to use different layers for different actions - parent window with width/height equal to container always rotateable with offset in the center and dragging/scaling nested element (with
draggable
option without any calculations). So in any dragged state the offset of the parent will be same in the same location, but it will show different part of the nested image.– extempl
Mar 23 at 14:46
There may be some problems with scaling, though, as it also needs offset. I'd play with scaling on the same layer as rotation then.
– extempl
Mar 23 at 14:47
By parent window, do you mean the stage or a new layer?
– Cristopher Namchee
Mar 24 at 1:12