kineticjs

editable Text option in kinetic js

回眸只為那壹抹淺笑 提交于 2019-11-29 04:59:29
I want to add Textbox or editable element to give the user the option to edit the text. This is my current code: var text = new Kinetic.Text({ text: "Sample Text", ---> i want to edit this text x: 50, y: 10, fill: "transparent", fontSize: 10, fontFamily: "Helvetica Neue", textFill: "#000", align: "center", verticalAlign: "middle", name:'TEXT' }); At the moment there does not seem to be any way to create editable text with Kinetic JS (see several threads about this at stackoverflow), some people suggest using an input field next to the canvas to edit the text, but my solution would be the

What is the difference between KineticJS draw methods?

三世轮回 提交于 2019-11-28 09:56:39
What is the difference between KineticJS methods layer.draw() , layer.drawScene() and layer.drawHit() ? Have a look at the source (v4.3.1) , l. 3381ff. These are defined on a Kinetic.Container . draw: function() { this.drawScene(); this.drawHit(); }, drawScene: function(canvas) { // do stuff }, drawHit: function() { // do stuff } The drawScene is used to draw the shapes onto the drawing canvas. The drawHit (see example ) is used to allow to modify the region where mouse events trigger events. This is done internally using a special Kinetic.HitCanvas . Update: You can find the code inside their

Angular JS identify an digest complete event and removing # from url in angular js during viewchange

谁都会走 提交于 2019-11-28 08:44:14
1) Is there any digest complete event which I can use to update my canvas. I have an angular app which has view for different properties of the canvas object. Whenever I change the property, once the digest is complete, If I can get the digest complete event I can update the canvas(using kineticJs) to redraw the chart with latest properties. Currently i am calling a method from the view 2) I am just using views and routing it to a new view whenever an object settings is opened. In this case the url also change with the webpage/#view.Its just the popup I dont need the #view at the end of the

Scaling to a fixed point in KineticJS

依然范特西╮ 提交于 2019-11-28 07:03:32
I'm having some problems with scaling a container to a fixed point. In my case I'm trying to scale (zoom) a stage to the mouse cursor. Here is a way to do with pure canvas: http://phrogz.net/tmp/canvas_zoom_to_cursor.html (as discussed at Zoom Canvas to Mouse Cursor ) I just can't get figure out how to apply the same logic while using the KineticJS API. Sample code: var position = this.stage.getUserPosition(); var scale = Math.max(this.stage.getScale().x + (0.05 * (scaleUp ? 1 : -1)), 0); this.stage.setScale(scale); // Adjust scale to position...? this.stage.draw(); juan.facorro After a lot of

Kineticjs dragBoundFunc for a rect in a rect

陌路散爱 提交于 2019-11-28 05:48:43
问题 i have following code to drag a smaller rect in a bigger rect. it is almost working, but its possible to move the orange rect out of the white one. Is there any solution for this behavior?? that the bigger rect is the dragborder for the small rect?? And another question... would it be possible to do it for a rect in any polygon as border? <!DOCTYPE HTML> <html> <head> <style> body {margin: 0px; padding: 20px;} canvas {border: 1px solid #777;} </style> </head> <body> <div id="container"></div>

Create vectors and collisions

北慕城南 提交于 2019-11-28 05:33:29
问题 I have a ball and a stick (for a billiard game). First the ball is placed in a position of a table. On clicking the ball the stick appears, in such a way that we can determine the angle by which stick is placed by clicking the ball (on clicking we determine the angle of mouse with respect to centre of ball and place the stick at that angle touching the ball). So now the stick is also in the table. Now I am dragging the stick along that angle only, if dragged in another angle than the initial

How can i stop all audio playing using Jquery

风流意气都作罢 提交于 2019-11-28 03:44:54
问题 I'm updating a div in a page using jquery mobile in order to play some animations. The animations also play sound through use of document.createElement('audio'); My problem is, when I update the page to another animation, the old sound keeps playing. Sorry, this is my first question and if it seems like im not phrasing it properly I apologise. Here is my code.. Here is the code of the animation to be loaded into the #animation div <!DOCTYPE HTML> <html> <head> <style> body { margin: 0px;

In Javascript, when performing a deep copy, how do I avoid a cycle, due to a property being “this”?

痞子三分冷 提交于 2019-11-27 23:36:49
I have some library code that is cycling endlessly on me. I'm not clear on how to best perform cycle detection and avoidance in javascript. i.e. there's no programmatic way of inspecting whether an object came from a "this" reference, is there? Here's the code. Thanks! setAttrs: function(config) { var go = Kinetic.GlobalObject; var that = this; // set properties from config if(config !== undefined) { function setAttrs(obj, c) { for(var key in c) { var val = c[key]; /* * if property is an object, then add an empty object * to the node and then traverse */ if(go._isObject(val) && !go._isArray

Scroll the page on drag with jQuery

℡╲_俬逩灬. 提交于 2019-11-27 18:32:58
I have tried using kinetic.js and the code below, however when I try this in IE11 it keeps jumping to the top every time I scroll: $("html").kinetic(); I want to make the page scrollable on tablets and IE10 and 11 so that users can just push the page up to scroll down as you would on mobile devices. How can I do this in pure-JS or jQuery without it jumping to the top? You can do this quite simply by recording the position of the mouse when clicked, and the current position when being dragged. Try this: var clicked = false, clickY; $(document).on({ 'mousemove': function(e) { clicked &&

What are the differences between group and layer in KineticJs

二次信任 提交于 2019-11-27 15:44:57
I am developing a HTML5 web application using KineticJS. I read that in KineticJS there are grouping and layering. As far as I know there are no differences between them. Can you tell me the differences? The basic difference: Groups are containers while Layers are separators. Group: A group is a container for shaped objects inside a layer. For example, a group might contain both a circle and a rectangle. A group can be manipulated and all elements within that group are similarly manipulated. For example, dragging a group will simultaneously drag a circle and rectangle contained in that group.