jquery-svg

jQuery SVG, why can't I addClass?

不羁岁月 提交于 2020-03-28 07:22:12
问题 I am using jQuery SVG. I can't add or remove a class to an object. Anyone know my mistake? The SVG: <rect class="jimmy" id="p5" x="200" y="200" width="100" height="100" /> The jQuery that won't add the class: $(".jimmy").click(function() { $(this).addClass("clicked"); }); I know the SVG and jQuery are working together fine because I can target the object and fire an alert when it's clicked: $(".jimmy").click(function() { alert('Handler for .click() called.'); }); 回答1: Edit 2016: read the next

Empty and non-clickable filling of SVG paths in SVG-edit

大兔子大兔子 提交于 2020-01-05 15:14:21
问题 I am doing a modiciation of SVG-edit which is an online SVG-editor: https://code.google.com/p/svg-edit/ I allow my users to draw shapes only with fillings set to "none". However now i want when my users draw these shapes, to allow them to hover over the shapes and display some information about them. When the shapes are "behind" some other shapes, althought they are visible because the filling is set to none, they are unclickable because the filling of the top shape is practically there but

Live drawing of a line in D3.js [closed]

隐身守侯 提交于 2019-12-29 03:33:12
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I'm just started with D3.js, and I want to create something like what we do in Paint to draw a line. The steps are should be the same: - Click on a point on the screen - Drag to the destination to create a line. What I'm having troubles now is when you drag your mouse to the destination, the line should move

Get SVG representation of div using jQuery SVG

独自空忆成欢 提交于 2019-12-25 18:32:28
问题 I am trying to get svg representation of a div.I am using jQuery SVG for this http://keith-wood.name/svg.html I am doing this on page load: var pad = null; $('.MyDiv').svg({onLoad: function(svg) { pad = svg; } }); and on every change inside div , i am doing this: var svg = $('.MyDiv').svg('get'); alert(svg.text); but i am getting some JS code in alert. i tried alerting svg.toSVG() but i am getting this : <svg version='1.1'></svg> in alert svg.toSVG() seems to work but i am getting empty svg

JointJS - Mouse click event triggers cell position change event

我的梦境 提交于 2019-12-23 04:48:25
问题 I need to define mouse click event for my each cell. I used cell:pointerup event; but this event is triggered when I change positions of cells too. How can I differentiate these 2 events? Thanks in advance. 回答1: What you can do is to create a custom element view and distinct click from dragging by checking whether a pointermove event was triggered between pointerdown and pointerup events. var ClickableView = joint.dia.ElementView.extend({ pointerdown: function () { this._click = true; joint

jquery animate for element attributes not style

陌路散爱 提交于 2019-12-19 05:34:25
问题 ASAIK jquery animate function accepts style properties only. but i want to animate the attributes of an element. consider a SVG element rectangle <svg> <rect id="rect1" x=10 y=20 width="100px" height="100px"> </svg> i want to animate the rectangle element attribute "x" and "y" something like below $("#rect1").animate({ x: 30, y: 40 }, 1500 ); but it is not correct way because animate function affects style not attribute of an element. i knew so many custom plugin is there like raphel.js .

How to call a function in the parent html document from an embedded svg

青春壹個敷衍的年華 提交于 2019-12-18 08:20:12
问题 I'm quite new to svg and I have to perform a task with it, but I'm having lots of troubles. I have an svg (a map for instance) with areas defined by paths. My goal is to trigger onClick a function external to the svg to do some stuff (for instance, retrieving by ajax some people data related to the area selected and show them outside the svg in the html page). What I'm not able to do is to trigger a function defined outside the svg from an element in the svg. I can do this if i add the svg

How to place text in the center of an svg path

跟風遠走 提交于 2019-12-18 04:13:00
问题 For rendering SVG I'm using jQuery SVG plugin. And, now I want to add text to each path and polygon. On jsFiddle you can see generated markup by plugin. For creating text I wrote the following code: var svgg = $("#rsr").svg('get'); var texts = svgg.createText(); svgg.textpath($("#Layer_x0020_1"),id, texts.string('We go '). span('up', { dy: -30, fill: 'red' }).span(',', { dy: 30 }). string(' then we go down, then up again')); In the code on jsFiddle you can see that the textpath tag exists,

Z-order and z-index in SVG for particular group or element

你说的曾经没有我的故事 提交于 2019-12-13 04:29:51
问题 i drawn one line in SVG using "path" tag and then i drawn circle on the same x value of line but the circle is behind the line. i want the circle element in front of line. how to set z-order or z-index to particular group or element in svg to display the element in front. i tried z-Index attribute to circle but its not working . <circle .... z-Index=1000> </circle> Thanks, Siva 回答1: SVG elements do not have a z-index that you can adjust. Their layering order is dependent on what order you

JavaScript - Is there a way how to draw SVG path UNDER the content?

别等时光非礼了梦想. 提交于 2019-12-12 04:35:41
问题 I need a path that goes UNDER the content (text) - is there a way how to do that? (as already been answered somewhere else, z-index doesnt affect svg paths) 回答1: You can declare PATH and TEXT in different SVG layers, and put one layer onto another like this <svg xmlns="http://www.w3.org/2000/svg" version="1.1" style="position:absolute;z-index:1"> <text x="100" y="15" fill="red">I love SVG</text> </svg> <svg xmlns="http://www.w3.org/2000/svg" version="1.1" style="position:absolute;z-index:0">