Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New class structure / es6 modules #28

Open
Fuzzyma opened this issue Nov 15, 2018 · 0 comments
Open

New class structure / es6 modules #28

Fuzzyma opened this issue Nov 15, 2018 · 0 comments

Comments

@Fuzzyma
Copy link
Member

Fuzzyma commented Nov 15, 2018

Directory structure

All modules are structured into the folders:

  • animation
  • elements
  • modules
    • core
    • optional
  • types
  • utils

All modules in the optional folder can be removed from the library without effecting the others.
All elements except the base classes + SVG.Doc can be removed without affecting other modules.

Class structure

  • SVG.Parent was merged with SVG.Element
  • SVG.Element was splitted into Dom and Element

Example:
Base > EventTarget > Dom > Element > Shape > Rect
Base > EventTarget > Dom > Element > Container > Doc

Module Bundling

All modules are bundle together in main.js. This bundle should be utilized by other people using es6. They can import all functions they need from there.

When the user wants his old plain SVG-Object, they can use the svg.js file which imports this object.
This is also used to bundle the es5 bundle and is currently run against the tests.

What has to be changed in the docs

  • Update usage note:
    • es5 users should include the es5 bundle + polyfills file (works with script tag)
    • es6 users should include SVG from svg.js or specific objects from the main.js
  • New page for Dom with all its methods
  • Update elements page with all its methods
  • Note, from which optional module a method is coming from

Methods of EventTarget

  • addEventListener - private
  • dispatch: returns the event
  • dispatchEvent - private
  • fire: returns the element
  • getEventHolder - private
  • getEventTarget - private
  • off
  • on
  • removeEventListener - private

Methods of Dom:

  • add
  • addTo
  • attr - accepts array as input now (attr() excepts array now to get multiple values at once #66)
  • children -> returns List
  • clear
  • clone -> does NOT append clone behind the element. Use insertAfter() instead
  • each
  • element: moved here from Bare
  • find - old select(). Returns List
  • first
  • get
  • getEventTarget (actually this should be private api)
  • has
  • id
  • index
  • last
  • matches
  • parent
  • put
  • putIn
  • remove
  • removeElement (private)
  • replace
  • round - round node attributes el.round(precision, [which Attributes = all])
  • toString
  • svg (Getting inner SVG content svg.js#700)
    • getter: svg(modifier, outerHTML = true), svg(outerHTML = true)
    • setter: svg(svgString, outerHTML = true)
  • words: move here from Bare
  • writeDataToDom (private?)

Methods of Element

  • center
  • cx
  • cy
  • defs
  • doc
  • getEventHolder (private)
  • height
  • inside
  • move
  • parents - does return all parents until it hits the given node: el.parents(until = document)
  • reference
  • setData - private?
  • writeDataToDom (overwritten from Dom - no second explanation needed)
  • x
  • y
  • bbox
  • rbox
  • point
  • ctm
  • screenCTM

Methods of Container

I am not sure if we should structure it like that. When someone wants to kow which methods are on the element, he might also want to use dom or event target methods. So how can we link that in a good way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant