2.0.0-preview.9 • Published 4 years ago

savagedom v2.0.0-preview.9

Weekly downloads
4
License
LGPL-3.0
Repository
github
Last release
4 years ago

SavageDOM - npm version Build Status semantic-release

SavageDOM is a lightweight module to create and manipulate SVG elements.

Getting Started

Installation

  • A direct download of the minified output is available in the dist directory
  • npm i -P savagedom to support bundlers

Usage

Automatically-generated documentation is available here.

This module functions as a utility wrapper on top of the existing DOM element definitons. All augmentations are manually applied by this module so no prototype manipulation happens.

Default Export element

  • element(svgElement, props?)

    • Wraps an SVGElement and returns the corresponding SavageDOMElement
    • An optional property object can also be specified, which will be applied to the new element
  • element.<tagName>(props?)

    • Invoking any method on element will construct a new SavageDOMElement with that tagName
    • An optional property object can also be specified, which will be applied to the new element

SavageDOMElement wrapper

The SavageDOMElement type is an additive wrapper, so any method that requires an SVGElement will accept a SavageDOMElement instead.

  • SavageDOMElement.get(key)

    • Fully-typed attribute access
    • Combines both native SVG attributes as well as available CSS style attributes
    • Returns deserialized value (depends on attribute)
  • SavageDOMElement.set(key, value) / SavageDOMElement.set(props)

    • Fully-typed attribute access
    • Combines both native SVG attributes as well as available CSS style attributes
    • Default serialization assumes value can be coerced to string
    • Supports single key, value args or props object of multiple keys/values
    • Additional processing exists for <funciri> and list-of types
  • SavageDOMElement.animateTo(timing, key, value) / SavageDOMElement.animateTo(timing, props)

    • Fully-typed attribute access
    • Combines both native SVG attributes as well as available CSS style attributes
    • Default serialization assumes value can be coerced to string
    • Supports single key, value args or props object of multiple keys/values
    • Only supports interpolation for: boolean, number, angle, length, and color as well as list of number, length, point, and transform
  • SavageDOMElement.once(event)

    • Utility wrapper around one time event listener
  • SavageDOMElement.add(svgElement, prefix?)

    • Adds any SVGElement beneath this element
    • Optional argument to prepend instead of append (default)
  • SavageDOMElement.add.<tagName>(props?)

    • Identical to element.<tagName>(props?) for constructing new elements
    • All element created this way will be appended to current element
  • SavageDOMElement.rm(svgElement)

    • Utility wrapper around Node.removeChild
  • SavageDOMElement.inject(document)

    • Inserts a copy of a Document into the current element
    • Document must be an SVG document with a top-level <svg> tag
    • This method will modify the input Document by migrating all defs to the parent <svg> of this element
    • All contents will be added inside of a <g> element
    • The same Document can be injected more than once independently
  • SavageDOMElement.sub

    • A live ArrayLike object that contains all sub-elements of this element
    • Accessing any sub-elements will return them as a wrapped SavageDOMElement
  • SavageDOMElement.subByTag.<tagName>

    • A live ArrayLike object that contains all sub-elements with the corresponding tagName under this element
    • Accessing any sub-elements will return them as a wrapped SavageDOMElement
2.0.0-preview.10

4 years ago

2.0.0-preview.11

4 years ago

2.0.0-preview.9

4 years ago

2.0.0-preview.8

5 years ago

2.0.0-preview.7

5 years ago

2.0.0-preview.6

5 years ago

2.0.0-preview.5

5 years ago

2.0.0-preview.4

5 years ago

2.0.0-preview.3

5 years ago

2.0.0-preview.2

5 years ago

2.0.0-preview.1

5 years ago

2.0.0-preview.0

5 years ago

1.4.4

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0-beta.5

5 years ago

1.0.0-beta.4

5 years ago

1.0.0-beta.3

6 years ago

1.0.0-beta.2

6 years ago

1.0.0-beta.1

6 years ago

1.0.0-beta.0

6 years ago

1.0.0-alpha.39

6 years ago

1.0.0-alpha.38

6 years ago

1.0.0-alpha.37

6 years ago

1.0.0-alpha.36

6 years ago

1.0.0-alpha.35

6 years ago

1.0.0-alpha.34

6 years ago

1.0.0-alpha.33

6 years ago

1.0.0-alpha.32

6 years ago

1.0.0-alpha.31

6 years ago

1.0.0-alpha.30

6 years ago

1.0.0-alpha.29

6 years ago

1.0.0-alpha.28

6 years ago

1.0.0-alpha.27

6 years ago

1.0.0-alpha.26

6 years ago

1.0.0-alpha.25

6 years ago

1.0.0-alpha.24

6 years ago

1.0.0-alpha.23

6 years ago

1.0.0-alpha.22

6 years ago

1.0.0-alpha.21

6 years ago

1.0.0-alpha.20

6 years ago

1.0.0-alpha.19

6 years ago

1.0.0-alpha.18

6 years ago

1.0.0-alpha.17

6 years ago

1.0.0-alpha.16

6 years ago

1.0.0-alpha.15

7 years ago

1.0.0-alpha.14

7 years ago

1.0.0-alpha.13

7 years ago

1.0.0-alpha.12

7 years ago

1.0.0-alpha.11

7 years ago

1.0.0-alpha.10

7 years ago

1.0.0-alpha.9

7 years ago

1.0.0-alpha.8

7 years ago

1.0.0-alpha.7

7 years ago

1.0.0-alpha.6

7 years ago

1.0.0-alpha.5

7 years ago

1.0.0-alpha.4

7 years ago

1.0.0-alpha.3

7 years ago

1.0.0-alpha.1

7 years ago

1.0.0-alpha.0

7 years ago