JQuery SVG
Введение в jQuery SVG
To use the jQuery SVG plugin include the CSS and the Javascript in the head section of your page. Для использования jQuery SVG plugin включите CSS и Javascript в заголовок страницы
<style type="text/css">@import "jquery.svg.css";</style> <script type="text/javascript" src="jquery.svg.js"></script>
Also include any extension packages you may want to use. For example: Так же можно использовать и расширения. Например:
<script type="text/javascript" src="jquery.svganim.js"></script>
Attach an SVG canvas to a
$(selector).svg();
You can pass additional parameters to this call as described below. Вы можете пропустить добавление параметров как описано ниже: Then, once loaded, retrieve the SVG instance and start working with it: Тогда, однажды загрузив, возьмите пример SVG и работайте с ним
var svg = $('#svgintro').svg('get'); svg.circle(130, 75, 50, {fill: 'none', stroke: 'red', strokeWidth: 3});
Some general notes on the JavaScript implementation:
Additional settings that contain a dash (-) in SVG should be written in camel-case without the dash. Settings that are reserved words in JavaScript must be followed by an underscore. For example, attributes stroke-width and class become:
svg.line(10, 10, 90, 90, {stroke: 'blue', strokeWidth: 2, class_: 'myline'});
For IE, a blank SVG document is initially loaded that registers itself with the plugin and allows access to its internal structure. This is the blank.svg document. Because of this, you must wait for the document to be loaded before accessing the SVG instance and using it. Use the onLoad setting to be notified when loading is complete. Additional parameters may be passed to the initial attachment call.
Список доступных полей и функций.
Подробная документация на англ. оригинал
$(selector).svg()
$(selector).svg({
loadURL: , // External document to load onLoad: null, // Callback once loaded settings: {}, // Additional settings for SVG element initPath: }) // Initial path for blank document
$(selector).svg(loadURL)
$(selector).svg(onLoad)
$(selector).svg('get')
// Retrieve SVG wrapper
$(selector).svg('destroy')
// Remove SVG functionality
$.svg.addExtension(name, extClass)
// Extend SVG functionality