Giter VIP home page Giter VIP logo

svg.foreignobject.js's Introduction

svg.foreignobject.js

A plugin for the svgjs.com library to create foreign object elements in svg.

See SVG Documentation on the foreignObject element for more details.

Svg.foreignobject.js is licensed under the terms of the MIT License.

Usage

Include this plugin after including the svg.js library in your html document.

To add a foreignobject

var canvas = SVG('canvas').size(1024, 550)
var fobj = canvas.foreignObject(100,100).attr({id: 'fobj'})

To add a child note

var txt = "some text that is quite long.  and it goes on and on.  and it's pointless really.  and the grammar is terrible.  blah. blah. blah"
fobj.appendChild("div", {id: 'mydiv', innerText: txt})

The first argument to appendChild is either a node or a string describing the type of element to create. The second argument is a list of attributes to set on the element.

Note that the foreignObject element can be manipulated with the standard svg.js methods (move(), rotate(), scale() etc.), whereas the contained node can be manipulated separately. For example if you embed a HTML element you can use jQuery (or whaever you choose) to manipulate the embedded object.

Example

See the provided sample.html

Dependencies

This plugin requires svg.js v0.12.

svg.foreignobject.js's People

Contributors

memloom-development avatar hunterhua avatar

Stargazers

Jiawei Hua avatar

Watchers

Jiawei Hua avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.