Skip to content
New issue

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

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

Already on GitHub? # to your account

Refactor: Make core a general "3D animation API", move parsing of steps to plugin #742

Open
henrikingo opened this issue Sep 11, 2019 · 2 comments

Comments

@henrikingo
Copy link
Member

henrikingo commented Sep 11, 2019

This is an idea @bartaz has discussed with me as I became active in this project. I'm writing down this ticket now triggered by #649.

The basic idea is to simplify the core even more, so that core just moves the viewport to given coordinates. Even the parsing of data-x/y/z attributes would move out of core to some kind of step-positioning plugin.

As a first pass, I'm going to include the concept of a step as a core object though. It is common for animation software to build animations out of steps, so this seems justified. This will result in a more complex api, not less.

Core objects:

  • a step
  • an order between steps (array & current index)
  • a camera (internally canvas + root objects)

The new API could therefore be:

addStep(element, coordinates, [index]) // default: append. This would be the `css()` part of current `initStep()`
removeStep(index)
getSteps() // return: array
getCurrentStep() // return: {index: ..., el: ..., coordinates: ...}

// Move camera to arbitrary coordinates
// Coordinates is essentially this object: https://github.com/impress/impress.js/blob/master/src/impress.js#L282
setCoordinates(coordinates)
getCoordinates()
panZoom(relativeCoordinates)

// The rest stay same as before, but goto() now becomes setCoordinates(getSteps()[target].coordinates))
goto(target) // as currently, target can be an index, step id
next()
prev()
init()
tear()
lib()

What could move out of core:

  • swipe() can now move to touch plugin and just call setCoordinates() repeatedly to animate the swipe.
  • Most of initAllSteps() and initStep() can become 1 or 2 new plugins, which parse DOM attributes and call addStep().
  • I believe addPreInitPlugin() can then be removed and rel and extras can become normal plugins triggered by impress:init.
    • A completely separate question is whether we should adopt the new import/export type modules. impress.js historically was always targeting state of the art JavaScript. But this ticket is valid either way.
@henrikingo henrikingo changed the title Refactor: Make core a general "3D animation API", move next/prev to plugin Refactor: Make core a general "3D animation API", move parsing of steps to plugin Sep 22, 2019
@janishutz
Copy link
Contributor

Honestly… really amazing idea.

@janishutz
Copy link
Contributor

I am going to be looking into doing this in December this year or January next year when I have time again to work on other projects than my current ones

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

No branches or pull requests

2 participants