KonvaJS: How to connect two shapes with an arrow so that arrow can be moved to new position using mouse? - konvajs

I have connected two custom shapes with arrow in konva. But after the connection, the arrow remains static. I cant move it to point to new position. Instead I will have to delete the arrow and redraw it. How to create an arrow that can be moved in any position(not just from pointer)
original
after moving the arrow with cursor

Related

iOS Spritekit Scrolling Menu

I am implementing a horizontal scrolling menu for a SpriteKit game and have become stuck as to how to go about this. My strategy was originally to add all of my menu items to the scene and just pan the camera horizontally according to swipes.
The problem with this is that the menu is revolving/circular (last item links to the first, etc) so even if I repeated the menu items infinitely, after swiping constantly one direction, I imagine a coordinate limit would be reached and the app would crash.
My next solution is to add one menu item in my camera view, one to the left, and one to the right. Then upon swiping the correct item would move into my camera view via SKAction and the original item would move away. I would then removechild the farthest node from the camera, and add the next item to the scene in the direction toward which I swiped. This way my x range (in points) would only be -displayWidth to displayWidth. The problem with this is that I would need to animate all of the menu items at the same time, and as they are separate nodes I have not seen a way to synchronize their animation.
Also I need to check the position of elements on the menu items and change their shaders when they reach the border of the screen. SKActions seem to block the SKScene update method so I am ideally trying to avoid SKActions.
Is there any viable strategy that I am missing here?
Since this is only a menu, it is ok to be a little inefficient.
What you do is have your menu cloned 2 times (so you have a total of 3). You place one of the clones to the left, and one to the right.
You then add all 3 of these into a parent SKNode. You should now have one SKNode with the 3 menu items in a long string. Make sure your anchor point is (0.5,0.5)
You then run the animation to pan left or right on the parent SKNode, with the condition that whenever you pass the edge of your original main menu, you jump in the opposite direction the width of the menu.
So let's say our menu is 400 (-199,200) points wide, and our screen is 300 points wide (-149,150). Once the parent point -200 (menu point 200 or right side of menu) aligns with screen point -150, you move the parent point to 200 (so menu point is -200 or left side of menu).
Since you are moving the parent node, all the clones will follow suit, and you only need to run 1 action.
I recommend using UIKit to create such a menu instead of SpriteKit. UICollectionView should be good for such a task.

changes to allowsCameraControl (swift 4)?

I have a simple SCNScene with an object placed in the center (for example, a cube). BEFORE the latest update to Swift 4, I enabled allowsCameraControl and the user could then rotate and manipulate (zoom in/out) the cube. Now, (Swift 4, iOS 11) with the exact same code, when the user manipulates the cube, SOMETIMES the direction you swipe your finger matches the direction the cube moves, while other times, the direction you move your finger causes the cube to move the opposite direction! It is NOT something that is always backwards or always correct, it can change as quickly as swiping one direction (correct cube movement), raising your finger, going back and trying to continue the same motion, but now the second swipe makes it rotate back the wrong way!
It almost seems like it's trying to use some specific point in the scene as a 'reference' of some kind. Like if that point is on the front of the object, a swipe left makes it move left. But if that point gets moved to the 'back' of the object, the next swipe left still moves the POINT left, but because it's in the 'back', moving left translates into the front of the object moving right. (with the same thing for up and down!)

Swift : Create region to UIPanGesture

I have this design here : http://imgur.com/XHMBUdj
I would like to allocate the left half of the screen(splitting vertically) to panning up and down for the blue bars and allocate the right half of the screen(splitting vertically) to panning up and down for the red bars.
I can already use UIPanGestureRecognizer, however, I just need help making the region in which if the user pans on the right side of the screen, "this" happens and if the user pans on the left side, "this" happens.
A friend of mine recommended using UIBezierPath. Could someone help me out? Code will be much appreciated!
I looks like it would be easier to have two UIPanGestureRecognizers.
In your view, you can add a subview that take up the left half on the screen that contains the blue bars and the microphone and add another subview that is on the right half of the screen containing the red bars and the music icon.
Then you can create two separate UIPanGestureRecognizers and add one to each of the views. Then each side will have its one recognizer that will take care of the side detection for you.

How to move (drag) a zoomed graph in overview pane?

When I'm in overview window and zoom in, some part of the graph is not visible. I want to drag the graph so that I can see it at the zoomed in size.
I tried the "Center on graph" button, but it zooms out the graph and centers it on the screen. I tried the direct and drag tool, which doesn't seem to do anything. What to do to accomplish this?
I want to drag the node in upper left corner so that I can see what it connects to:
Right-click and drag (Gephi 0.9.1 for Mac).
To move the graph at a given level of zoom, you can right click.
The keyword was "navigation" :)
Happy work!
I figured out a way to do this with the mouse. If you want to zoom in on an area, you need to position your mouse over the area you want to see, and then use the scroll wheel to zoom in. So for the case above, zoom out until you can see everything, and then hover your mouse over the area you want to zoom in on (the upper left node in this case), and you scroll your mouse wheel to zoom. That will allow you to zoom in on an area without having to move the object on the canvas first.

Container scrolling on draggable moved to left or top

is there a good way to make the container div expand to the left and top when a draggable is dragged outside of its borders?
When you drag to the right or down the container div is properly extended, and scrollbars appear as needed. Yet moving to left or top means that the draggable items has negative top / left position, so the container is not expanded.
Here's a fiddle that demonstrates the existing dragging behaviour: http://jsfiddle.net/NPC42/Un23w/1/, but this can also be seen on the official jQueryUI demos too (http://jqueryui.com/demos/draggable/#default).
I'd like to be able to expand to the top / left too :)
A brute-force approach would be to:
Reset all of the object's positions on the container div to that no negative top / left is required (including the object being dragged).
Change the scrolling position to make it look as if the objects are still on their spots.
But for many objects in the container this could cause a lot of flicker, or even slowdown, so I don't really want to go in that direction. Any suggestions are welcome!
The problem is that every html element has an absolute (0,0) origin coordinate in the top left corner. When you drag in that direction the coordinates for the dragable become negative. However the scrollbars can not become negative, their size can only grow in a positive direction.
I can imagine a custom scrollbars widget that can adjust in a negative direction when you drag below (0,0). Also try having a container inside of another container with the inner one move around so that all of the objects inside it don't have to be individually moved. I don't know of any in existence as it would be kinda weird to have a negative scroll offset.

Resources