├── .editorconfig
├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ ├── ---feature-request.md
│ ├── --bug-report.md
│ └── -questions---help.md
└── workflows
│ └── test.yml
├── .gitignore
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── LICENSE
├── README.md
├── README_CN.md
├── demo
├── .editorconfig
├── clapper.mp3
├── common
│ └── highlight.pack.js
├── features.html
├── images
│ ├── card.gif
│ ├── card.png
│ ├── circleburst.gif
│ ├── circleburst.png
│ ├── clapperboard.png
│ ├── cube.png
│ ├── daybrush.gif
│ ├── home.afdesign
│ ├── home.svg
│ ├── medium.afdesign
│ ├── medium.svg
│ ├── motiongraphic.png
│ ├── ori
│ │ ├── card.png
│ │ ├── circleburst.png
│ │ ├── clapperboard.png
│ │ ├── cube.png
│ │ ├── motiongraphic.png
│ │ ├── raindrop.png
│ │ ├── search.png
│ │ ├── snow.png
│ │ └── tree.png
│ ├── panda.gif
│ ├── raindrop.png
│ ├── search.png
│ ├── snow.png
│ ├── svg.svg
│ ├── tree.gif
│ ├── tree.png
│ ├── twitter.afdesign
│ ├── twitter.svg
│ ├── youtube.afdesign
│ └── youtube.svg
└── index.html
├── examples
├── circleburst.html
├── clapper.html
├── clapper.mp3
├── cube.html
├── dissolve.gif
├── function.html
├── image
│ ├── 1.jpg
│ └── 2.jpg
├── iphone.html
├── logo.gif
├── main.gif
├── motion.gif
├── motion.html
├── parallax.gif
├── raindrop.gif
├── scenejs.gif
├── search.gif
├── shape.gif
├── shape.html
├── test.html
├── test2.html
├── test3.html
└── transition.html
├── jsdoc.json
├── lerna.json
├── package.json
├── packages
├── demo
│ ├── package.json
│ ├── rollup.config.js
│ ├── src
│ │ ├── features
│ │ │ ├── css
│ │ │ │ ├── index.css
│ │ │ │ └── monokai-sublime.css
│ │ │ ├── data.ts
│ │ │ ├── index.ts
│ │ │ └── page.ts
│ │ └── index
│ │ │ ├── ExamplesPage.ts
│ │ │ ├── FeaturesPage.ts
│ │ │ ├── Header.ts
│ │ │ ├── MainPage.ts
│ │ │ ├── StartedPage.ts
│ │ │ ├── Store.ts
│ │ │ ├── css
│ │ │ ├── index.css
│ │ │ ├── page1.css
│ │ │ ├── page2.css
│ │ │ ├── page3.css
│ │ │ └── page4.css
│ │ │ ├── index.ts
│ │ │ └── utils.ts
│ └── tsconfig.json
├── react-scenejs
│ ├── .gitignore
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── package.json
│ ├── public
│ │ ├── index.html
│ │ ├── manifest.json
│ │ └── robots.txt
│ ├── rollup.config.js
│ ├── src
│ │ ├── App.css
│ │ ├── App.test.tsx
│ │ ├── App.tsx
│ │ ├── index.css
│ │ ├── index.tsx
│ │ ├── logo.svg
│ │ ├── react-app-env.d.ts
│ │ ├── react-scenejs
│ │ │ ├── index.tsx
│ │ │ ├── useFrame.tsx
│ │ │ ├── useNowFrame.tsx
│ │ │ ├── useScene.tsx
│ │ │ └── useSceneItem.tsx
│ │ ├── reportWebVitals.ts
│ │ └── setupTests.ts
│ ├── tsconfig.build.json
│ ├── tsconfig.declaration.json
│ └── tsconfig.json
├── scenejs
│ ├── .editorconfig
│ ├── .gitignore
│ ├── .npmignore
│ ├── .travis.yml
│ ├── CHANGELOG.md
│ ├── CODE_OF_CONDUCT.md
│ ├── LICENSE
│ ├── README.md
│ ├── README_CN.md
│ ├── karma.conf.js
│ ├── mocha.opts
│ ├── package.json
│ ├── rollup.config.demo.js
│ ├── rollup.config.js
│ ├── src
│ │ ├── Animator.ts
│ │ ├── Frame.ts
│ │ ├── PropertyObject.ts
│ │ ├── Scene.ts
│ │ ├── SceneItem.ts
│ │ ├── consts.ts
│ │ ├── easing.ts
│ │ ├── index.cjs.ts
│ │ ├── index.ts
│ │ ├── index.umd.ts
│ │ ├── presets.ts
│ │ ├── reactive
│ │ │ ├── Frame.ts
│ │ │ ├── NowFrame.ts
│ │ │ ├── Scene.ts
│ │ │ ├── SceneItem.ts
│ │ │ ├── index.ts
│ │ │ └── reactive.ts
│ │ ├── types.ts
│ │ ├── utils.ts
│ │ └── utils
│ │ │ ├── dot.ts
│ │ │ └── property.ts
│ ├── test
│ │ ├── manual
│ │ │ └── easing.html
│ │ └── unit
│ │ │ ├── Animator.spec.ts
│ │ │ ├── Frame.spec.ts
│ │ │ ├── PropertyObject.spec.ts
│ │ │ ├── Scene.spec.ts
│ │ │ ├── SceneItem.spec.ts
│ │ │ ├── TestHelper.ts
│ │ │ ├── easing.spec.ts
│ │ │ ├── injections
│ │ │ └── ClassListInjection.ts
│ │ │ ├── presets.spec.ts
│ │ │ ├── utils.spec.ts
│ │ │ └── utils
│ │ │ ├── color.spec.ts
│ │ │ ├── dot.spec.ts
│ │ │ └── property.spec.ts
│ ├── tsconfig.declaration.json
│ ├── tsconfig.json
│ ├── tsconfig.test.json
│ └── tslint.json
├── svelte-scenejs
│ ├── .gitignore
│ ├── .svelte-kit
│ │ └── tsconfig.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── global.d.ts
│ ├── package.json
│ ├── public
│ │ ├── favicon.png
│ │ ├── global.css
│ │ └── index.html
│ ├── rollup.config.js
│ ├── src
│ │ ├── app.d.ts
│ │ ├── app.html
│ │ ├── routes
│ │ │ ├── +page.svelte
│ │ │ ├── Motion.svelte
│ │ │ └── Scene.svelte
│ │ └── svelte-scenejs
│ │ │ ├── index.ts
│ │ │ ├── useFrame.ts
│ │ │ ├── useNowFrame.ts
│ │ │ ├── useScene.ts
│ │ │ └── useSceneItem.ts
│ ├── svelte.config.js
│ ├── tsconfig.declaration.json
│ ├── tsconfig.json
│ └── vite.config.js
├── vue-scenejs
│ ├── .browserslistrc
│ ├── .gitignore
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── demo
│ │ ├── App.vue
│ │ ├── index.ts
│ │ └── shims-vue.d.ts
│ ├── package.json
│ ├── postcss.config.js
│ ├── public
│ │ ├── favicon.ico
│ │ └── index.html
│ ├── rollup.config.js
│ ├── src
│ │ ├── index.ts
│ │ ├── useFrame.ts
│ │ ├── useNowFrame.ts
│ │ ├── useScene.ts
│ │ └── useSceneItem.ts
│ ├── tsconfig.declaration.json
│ └── tsconfig.json
└── vue2-scenejs
│ ├── .browserslistrc
│ ├── .eslintrc.js
│ ├── .gitignore
│ ├── CHANGELOG.md
│ ├── LICENSE
│ ├── README.md
│ ├── demo
│ ├── App.vue
│ ├── index.ts
│ └── shims-vue.d.ts
│ ├── package.json
│ ├── postcss.config.js
│ ├── public
│ ├── favicon.ico
│ └── index.html
│ ├── rollup.config.js
│ ├── src
│ ├── index.ts
│ ├── useFrame.ts
│ ├── useNowFrame.ts
│ ├── useScene.ts
│ └── useSceneItem.ts
│ ├── tsconfig.declaration.json
│ └── tsconfig.json
├── static
└── scripts
│ └── custom.js
└── yarn.lock
/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [{*.js,*.ts}]
5 | charset = utf-8
6 | end_of_line = lf
7 | indent_style = space
8 | indent_size = 4
9 | insert_final_newline = true
10 | max_line_length = 80
11 | trim_trailing_whitespace = true
12 |
13 | [{package.json,.travis.yml}]
14 | indent_style = space
15 | indent_size = 4
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: daybrush # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/---feature-request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: "\U0001F680 Feature request"
3 | about: Suggest an idea for this project
4 |
5 | ---
6 |
7 | **Is your feature request related to a problem? Please describe.**
8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9 |
10 | **Describe the solution you'd like**
11 | A clear and concise description of what you want to happen.
12 |
13 | **Describe alternatives you've considered**
14 | A clear and concise description of any alternative solutions or features you've considered.
15 |
16 | **Additional context**
17 | Add any other context or screenshots about the feature request here.
18 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/--bug-report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: "\U0001F41BBug report"
3 | about: Create a report to help us improve
4 |
5 | ---
6 | ## Environments
7 | * Framework name:
8 | * Framework version:
9 | * Scene.js Component version:
10 | * Testable Address(optional):
11 |
12 | ## Description
13 |
14 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/-questions---help.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: "❓Questions & Help"
3 | about: I have questions or need help with scenejs
4 |
5 | ---
6 |
7 |
8 | ## Environments
9 | * Framework name:
10 | * Framework version:
11 | * Moveable Component version:
12 | * Testable Address(optional):
13 |
14 | ## Description
15 |
16 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: Run tests
2 | on: [push, pull_request]
3 | jobs:
4 | unit:
5 | runs-on: ubuntu-latest
6 | steps:
7 | - uses: actions/checkout@v2
8 | - uses: actions/setup-node@v2.1.5
9 | with:
10 | node-version: 14.15.4
11 | - name: install
12 | run: npm install
13 | working-directory: ./packages/scenejs
14 | - name: lint
15 | run: npm run lint
16 | working-directory: ./packages/scenejs
17 | - name: test
18 | run: npm run coverage
19 | working-directory: ./packages/scenejs
20 | - name: Coveralls GitHub Action
21 | uses: coverallsapp/github-action@v1.1.2
22 | with:
23 | base-path: ./packages/scenejs
24 | path-to-lcov: ./packages/scenejs/coverage/lcov.info
25 | github-token: ${{ secrets.GITHUB_TOKEN }}
26 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | *.DS_Store
3 | .DS_Store
4 | doc/
5 | dist/
6 | packages/*/dist
7 | demo/dist/
8 | release/
9 | npm-debug.log*
10 | coverage/
11 | jsdoc/
12 | doc/
13 | outjs/
14 | declaration/
15 | build/
16 | .vscode/
17 | rollup-plugin-visualizer/
18 | statistics/
19 | .scene_cache
20 | *.mp4
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Daybrush
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/demo/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [{*.js}]
5 | charset = utf-8
6 | end_of_line = lf
7 | indent_style = space
8 | indent_size = 2
9 | insert_final_newline = true
10 | max_line_length = 80
11 | trim_trailing_whitespace = true
12 |
13 | [{package.json,.travis.yml}]
14 | indent_style = space
15 | indent_size = 4
--------------------------------------------------------------------------------
/demo/clapper.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/clapper.mp3
--------------------------------------------------------------------------------
/demo/features.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
19 | Scene.js Features Documentation
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
40 |
42 |
44 |
45 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
63 |
64 |
--------------------------------------------------------------------------------
/demo/images/card.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/card.gif
--------------------------------------------------------------------------------
/demo/images/card.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/card.png
--------------------------------------------------------------------------------
/demo/images/circleburst.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/circleburst.gif
--------------------------------------------------------------------------------
/demo/images/circleburst.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/circleburst.png
--------------------------------------------------------------------------------
/demo/images/clapperboard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/clapperboard.png
--------------------------------------------------------------------------------
/demo/images/cube.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/cube.png
--------------------------------------------------------------------------------
/demo/images/daybrush.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/daybrush.gif
--------------------------------------------------------------------------------
/demo/images/home.afdesign:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/home.afdesign
--------------------------------------------------------------------------------
/demo/images/home.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/demo/images/medium.afdesign:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/medium.afdesign
--------------------------------------------------------------------------------
/demo/images/medium.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/demo/images/motiongraphic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/motiongraphic.png
--------------------------------------------------------------------------------
/demo/images/ori/card.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/ori/card.png
--------------------------------------------------------------------------------
/demo/images/ori/circleburst.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/ori/circleburst.png
--------------------------------------------------------------------------------
/demo/images/ori/clapperboard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/ori/clapperboard.png
--------------------------------------------------------------------------------
/demo/images/ori/cube.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/ori/cube.png
--------------------------------------------------------------------------------
/demo/images/ori/motiongraphic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/ori/motiongraphic.png
--------------------------------------------------------------------------------
/demo/images/ori/raindrop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/ori/raindrop.png
--------------------------------------------------------------------------------
/demo/images/ori/search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/ori/search.png
--------------------------------------------------------------------------------
/demo/images/ori/snow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/ori/snow.png
--------------------------------------------------------------------------------
/demo/images/ori/tree.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/ori/tree.png
--------------------------------------------------------------------------------
/demo/images/panda.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/panda.gif
--------------------------------------------------------------------------------
/demo/images/raindrop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/raindrop.png
--------------------------------------------------------------------------------
/demo/images/search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/search.png
--------------------------------------------------------------------------------
/demo/images/snow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/snow.png
--------------------------------------------------------------------------------
/demo/images/svg.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/demo/images/tree.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/tree.gif
--------------------------------------------------------------------------------
/demo/images/tree.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/tree.png
--------------------------------------------------------------------------------
/demo/images/twitter.afdesign:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/twitter.afdesign
--------------------------------------------------------------------------------
/demo/images/twitter.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/demo/images/youtube.afdesign:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/demo/images/youtube.afdesign
--------------------------------------------------------------------------------
/demo/images/youtube.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/examples/clapper.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/examples/clapper.mp3
--------------------------------------------------------------------------------
/examples/dissolve.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/examples/dissolve.gif
--------------------------------------------------------------------------------
/examples/function.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
146 |
147 |
148 |
149 |
150 |
187 |
188 |
--------------------------------------------------------------------------------
/examples/image/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/examples/image/1.jpg
--------------------------------------------------------------------------------
/examples/image/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/examples/image/2.jpg
--------------------------------------------------------------------------------
/examples/iphone.html:
--------------------------------------------------------------------------------
1 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
148 |
149 |
150 |
151 |
--------------------------------------------------------------------------------
/examples/logo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/examples/logo.gif
--------------------------------------------------------------------------------
/examples/main.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/examples/main.gif
--------------------------------------------------------------------------------
/examples/motion.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/examples/motion.gif
--------------------------------------------------------------------------------
/examples/motion.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
16 |
17 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/examples/parallax.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/examples/parallax.gif
--------------------------------------------------------------------------------
/examples/raindrop.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/examples/raindrop.gif
--------------------------------------------------------------------------------
/examples/scenejs.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/examples/scenejs.gif
--------------------------------------------------------------------------------
/examples/search.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/examples/search.gif
--------------------------------------------------------------------------------
/examples/shape.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/examples/shape.gif
--------------------------------------------------------------------------------
/examples/shape.html:
--------------------------------------------------------------------------------
1 |
2 |
15 |
18 |
19 |
60 |
--------------------------------------------------------------------------------
/examples/test.html:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
--------------------------------------------------------------------------------
/examples/test2.html:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
--------------------------------------------------------------------------------
/examples/test3.html:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
--------------------------------------------------------------------------------
/examples/transition.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/jsdoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "plugins": [],
3 | "recurseDepth": 10,
4 | "opts": {
5 | "template": "./node_modules/daybrush-jsdoc-template",
6 | "destination": "./doc/"
7 | },
8 | "source": {
9 | "include": [
10 | "./packages/scenejs/src/",
11 | "./packages/scenejs/src/reactive",
12 | "./packages/react-scenejs/src/react-scenejs/",
13 | "./packages/vue-scenejs/src/",
14 | "./packages/vue2-scenejs/src/",
15 | "./packages/svelte-scenejs/src/svelte-scenejs/",
16 | "./README.md",
17 | "./node_modules/@scena/event-emitter/src/"
18 | ],
19 | "includePattern": "(.+\\.js(doc|x)?|.+\\.ts(doc|x)?)$",
20 | "excludePattern": "(^|\\/|\\\\)_"
21 | },
22 | "sourceType": "module",
23 | "tags": {
24 | "allowUnknownTags": true,
25 | "dictionaries": [
26 | "jsdoc",
27 | "closure"
28 | ]
29 | },
30 | "templates": {
31 | "cleverLinks": false,
32 | "monospaceLinks": false,
33 | "default": {
34 | "staticFiles": {
35 | "include": [
36 | "./static"
37 | ]
38 | }
39 | }
40 | },
41 | "linkMap": {
42 | "IObject": "http://daybrush.com/utils/release/latest/doc/global.html#ObjectInterface"
43 | },
44 | "docdash": {
45 | "menu": {
46 | "Github repo": {
47 | "href": "https://github.com/daybrush/scenejs",
48 | "target": "_blank",
49 | "class": "menu-item",
50 | "id": "repository"
51 | },
52 | "Features": {
53 | "href": "https://daybrush.com/scenejs/features.html",
54 | "target": "_blank",
55 | "class": "menu-item",
56 | "id": "features"
57 | }
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/lerna.json:
--------------------------------------------------------------------------------
1 | {
2 | "npmClient": "yarn",
3 | "useWorkspaces": true,
4 | "packages": [
5 | "packages/*"
6 | ],
7 | "version": "independent",
8 | "lernaHelperOptions": {
9 | "deployFileMap": [
10 | {
11 | "basePath": "packages/scenejs/dist",
12 | "dists": [
13 | "demo/release/{{version}}/dist",
14 | "demo/release/latest/dist"
15 | ]
16 | },
17 | {
18 | "basePath": "doc",
19 | "dists": [
20 | "demo/release/{{version}}/doc",
21 | "demo/release/latest/doc"
22 | ]
23 | }
24 | ],
25 | "beforeReleaseScripts": [
26 | "npm run packages:build",
27 | "npm run demo:build",
28 | "npm run deploy"
29 | ]
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "scenejs-root",
3 | "version": "0.0.0",
4 | "description": "JavaScript & CSS timeline-based animation library",
5 | "sideEffects": false,
6 | "private": true,
7 | "repository": {
8 | "type": "git",
9 | "url": "https://github.com/daybrush/scenejs.git"
10 | },
11 | "keywords": [
12 | "scene",
13 | "scene.js",
14 | "scenejs",
15 | "keyframes",
16 | "timeline",
17 | "animate",
18 | "animation",
19 | "css",
20 | "requestAnimationFrame",
21 | "motion"
22 | ],
23 | "author": "Daybrush",
24 | "license": "MIT",
25 | "bugs": {
26 | "url": "https://github.com/daybrush/scenejs/issues"
27 | },
28 | "homepage": "https://daybrush.com/scenejs",
29 | "scripts": {
30 | "bootstrap": "lerna bootstrap",
31 | "build": "npm run build --prefix ./packages/scenejs",
32 | "packages:update": "lerna-helper version",
33 | "packages:build": "npm run build --prefix packages/scenejs && lerna run build --ignore demo",
34 | "packages:publish": "lerna-helper publish --commit 'chore: publish packages' --ignore demo",
35 | "changelog": "lerna-helper changelog --type all --base scenejs",
36 | "doc": "rm -rf ./doc && jsdoc -c jsdoc.json",
37 | "demo:start": "rollup -c rollup.config.demo.js -w",
38 | "demo:build": "rm -rf ./demo/dist && npm run build --prefix packages/demo && npm run doc",
39 | "demo:deploy": "gh-pages -d ./demo --dest=./ --add --remote origin",
40 | "deploy": "lerna-helper deploy --base scenejs",
41 | "release": "lerna-helper release --base scenejs"
42 | },
43 | "devDependencies": {
44 | "@cfcs/cli": "^0.0.3",
45 | "@daybrush/jsdoc": "^0.4.3",
46 | "@daybrush/release": "^0.7.1",
47 | "cpx": "1.5.0",
48 | "daybrush-jsdoc-template": "^1.8.0",
49 | "gh-pages": "^2.0.1",
50 | "intercept-stdout": "0.1.2",
51 | "lerna": "^4.0.0",
52 | "lerna-changelog": "2.2.0",
53 | "typescript": "^4.5.0 <4.6.0"
54 | },
55 | "workspaces": {
56 | "packages": [
57 | "packages/*"
58 | ],
59 | "nohoist": [
60 | "**/@egjs/build-helper",
61 | "**/@egjs/build-helper/**",
62 | "**/rollup-plugin-vue",
63 | "**/rollup-plugin-vue/**",
64 | "**/karma",
65 | "**/karma/**",
66 | "**/karma-*",
67 | "**/karma-*/**",
68 | "**/@types/chai",
69 | "**/@types/chai/**",
70 | "**/@types/karma-chai",
71 | "**/@types/karma-chai/**",
72 | "**/@types/mocha",
73 | "**/@types/mocha/**",
74 | "**/@vue/*",
75 | "**/@vue/*/**",
76 | "**/@cfcs/vue2",
77 | "**/@cfcs/vue2/**",
78 | "**/@cfcs/vue3",
79 | "**/@cfcs/vue3/**",
80 | "**/vue",
81 | "**/vue/**",
82 | "**/@sveltejs/*",
83 | "**/@sveltejs/*/**",
84 | "**/svelte",
85 | "**/svelte/**",
86 | "**/vite",
87 | "**/vite/**"
88 | ]
89 | },
90 | "resolutions": {
91 | "@daybrush/builder": "^0.2.0",
92 | "@daybrush/utils": "^1.10.2",
93 | "@types/react": "^18.0.26",
94 | "@types/react-dom": "^18.0.9",
95 | "typescript": "^4.5.0 <4.6.0",
96 | "@scena/event-emitter": "^1.0.3",
97 | "css-styled": "^1.0.0",
98 | "order-map": "^0.3.1",
99 | "tslib": "^2.4.0"
100 | },
101 | "overrides": {
102 | "@daybrush/builder": "^0.2.0",
103 | "@daybrush/utils": "^1.10.2",
104 | "@types/react": "^18.0.26",
105 | "@types/react-dom": "^18.0.9",
106 | "typescript": "^4.5.0 <4.6.0",
107 | "@scena/event-emitter": "^1.0.3",
108 | "css-styled": "^1.0.0",
109 | "order-map": "^0.3.1",
110 | "tslib": "^2.4.0"
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/packages/demo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "demo",
3 | "version": "0.0.0",
4 | "description": "Scene.js demo",
5 | "private": true,
6 | "repository": {
7 | "type": "git",
8 | "url": "https://github.com/daybrush/scenejs.git"
9 | },
10 | "keywords": [
11 | "scene",
12 | "scene.js",
13 | "scenejs",
14 | "keyframes",
15 | "timeline",
16 | "animate",
17 | "animation",
18 | "css",
19 | "requestAnimationFrame",
20 | "motion"
21 | ],
22 | "author": "Daybrush",
23 | "license": "MIT",
24 | "bugs": {
25 | "url": "https://github.com/daybrush/scenejs/issues"
26 | },
27 | "homepage": "https://daybrush.com/scenejs",
28 | "scripts": {
29 | "build": "rm -rf ../../demo/dist && rollup -c rollup.config.js"
30 | },
31 | "dependencies": {
32 | "@daybrush/page": "^0.2.0",
33 | "@daybrush/utils": "^1.10.2",
34 | "scenejs": "~1.10.3",
35 | "shape-svg": "^0.3.1"
36 | },
37 | "devDependencies": {
38 | "@daybrush/builder": "^0.2.0",
39 | "rollup-plugin-css-only": "^4.3.0",
40 | "typescript": "^4.5.0 <4.6.0"
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/packages/demo/rollup.config.js:
--------------------------------------------------------------------------------
1 | const builder = require("@daybrush/builder");
2 | const cssonly = require("rollup-plugin-css-only");
3 | const { resolve } = require("path");
4 |
5 | module.exports = builder([
6 | {
7 | input: './src/index/index.ts',
8 | output: "../../demo/dist/index.js",
9 | format: "iife",
10 | exports: "named",
11 | plugins: [cssonly({
12 | output: "index.css",
13 | })],
14 | resolve: true,
15 | uglify: false,
16 | },
17 | {
18 | input: './src/features/index.ts',
19 | output: "../../demo/dist/features.js",
20 | format: "iife",
21 | exports: "named",
22 | plugins: [cssonly({
23 | output: "features.css",
24 | })],
25 | resolve: true,
26 | uglify: true,
27 | },
28 | ]);
29 |
--------------------------------------------------------------------------------
/packages/demo/src/features/css/monokai-sublime.css:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Monokai Sublime style. Derived from Monokai by noformnocontent http://nn.mit-license.org/
4 |
5 | */
6 |
7 | .hljs {
8 | display: block;
9 | overflow-x: auto;
10 | padding: 0.5em;
11 | background: #23241f;
12 | }
13 |
14 | .hljs,
15 | .hljs-tag,
16 | .hljs-subst {
17 | color: #f8f8f2;
18 | }
19 |
20 | .hljs-strong,
21 | .hljs-emphasis {
22 | color: #a8a8a2;
23 | }
24 |
25 | .hljs-bullet,
26 | .hljs-quote,
27 | .hljs-number,
28 | .hljs-regexp,
29 | .hljs-literal,
30 | .hljs-link {
31 | color: #ae81ff;
32 | }
33 |
34 | .hljs-code,
35 | .hljs-title,
36 | .hljs-section,
37 | .hljs-selector-class {
38 | color: #a6e22e;
39 | }
40 |
41 | .hljs-strong {
42 | font-weight: bold;
43 | }
44 |
45 | .hljs-emphasis {
46 | font-style: italic;
47 | }
48 |
49 | .hljs-keyword,
50 | .hljs-selector-tag,
51 | .hljs-name,
52 | .hljs-attr {
53 | color: #f92672;
54 | }
55 |
56 | .hljs-symbol,
57 | .hljs-attribute {
58 | color: #66d9ef;
59 | }
60 |
61 | .hljs-params,
62 | .hljs-class .hljs-title {
63 | color: #f8f8f2;
64 | }
65 |
66 | .hljs-string,
67 | .hljs-type,
68 | .hljs-built_in,
69 | .hljs-builtin-name,
70 | .hljs-selector-id,
71 | .hljs-selector-attr,
72 | .hljs-selector-pseudo,
73 | .hljs-addition,
74 | .hljs-variable,
75 | .hljs-template-variable {
76 | color: #e6db74;
77 | }
78 |
79 | .hljs-comment,
80 | .hljs-deletion,
81 | .hljs-meta {
82 | color: #75715e;
83 | }
84 |
--------------------------------------------------------------------------------
/packages/demo/src/features/index.ts:
--------------------------------------------------------------------------------
1 | import { Pages, Navigations, ExportMouse, ExportCSS } from "./page";
2 | import { datas } from "./data";
3 | import * as nativeUtils from "@daybrush/utils";
4 | import "./css/index.css";
5 | import "./css/monokai-sublime.css";
6 |
7 | declare var utils: typeof nativeUtils;
8 | declare var hljs: any;
9 |
10 | document.querySelector(".container_overview")!.insertAdjacentHTML("beforeend", Pages(datas));
11 | document.querySelector(".classes")!.innerHTML = Navigations(datas);
12 |
13 | let exportMouseCount = 0;
14 | utils.toArray(document.querySelectorAll(".feature")).forEach(feature => {
15 | utils.toArray(feature.querySelectorAll(".example")).forEach(example => {
16 | const exampleScript = example.querySelector("script");
17 | const code = exampleScript.innerText.trim();
18 | const showCode = code
19 | .replace("/*mouse*/", "")
20 | .replace(/;\/\*play\*\//g, ".play();")
21 | .replace(";/*playcss*/", ".playCSS();");
22 | example.querySelector(".code").innerText = showCode;
23 |
24 | const script = document.createElement("script");
25 | const id = exampleScript.getAttribute("data-id");
26 | const value = exampleScript.getAttribute("data-value");
27 | const selector = `[data-${id}${value ? `='${value}'` : ""}]`;
28 | let scriptCode = code;
29 |
30 | if (code.indexOf("/*mouse*/") > -1) {
31 | scriptCode = scriptCode
32 | .replace("/*mouse*/", `var scene${++exportMouseCount} = `)
33 | .replace(/;\/\*play\*\//g, ExportMouse(selector, exportMouseCount))
34 | .replace(";/*playcss*/", ExportCSS(selector));
35 | } else {
36 | scriptCode = scriptCode.replace(/;\/\*play\*\//g, ExportCSS(selector));
37 | }
38 | utils.addEvent(example, "click", e => {
39 | // e.preventDefault();
40 | });
41 | script.innerHTML = scriptCode;
42 |
43 | example.appendChild(script);
44 | });
45 | });
46 | hljs.initHighlightingOnLoad();
47 |
--------------------------------------------------------------------------------
/packages/demo/src/index/ExamplesPage.ts:
--------------------------------------------------------------------------------
1 | import Page from "@daybrush/page";
2 | import { add } from "./Store";
3 |
4 | const page3 = new Page(".page.page3");
5 |
6 | add(page3);
7 |
--------------------------------------------------------------------------------
/packages/demo/src/index/Header.ts:
--------------------------------------------------------------------------------
1 | import { $, addClass, removeClass, toArray, addEvent, hasClass } from "@daybrush/utils";
2 | import { pages } from "./Store";
3 | import { scroll } from "./utils";
4 | import NativeScene, { EasingFunction } from "scenejs";
5 |
6 | declare var Scene: typeof NativeScene & {
7 | EASE_IN_OUT: EasingFunction,
8 | };
9 |
10 | const body = document.body;
11 | const nav = $(`nav`);
12 | const navButon = $(`.nav_button`);
13 | const menus = $(`nav [data-item] a`, true);
14 | const navScene = new Scene({
15 | "nav": {
16 | 0: {
17 | "background-color": "rgba(255, 255, 255, 0)",
18 | },
19 | 0.5: {
20 | "background-color": "rgba(255, 255, 255, 0.7)",
21 | },
22 | },
23 | "nav .half": {
24 | 0.2: {
25 | transform: {
26 | translate: "-100%",
27 | translate2: "-15vw",
28 | },
29 | },
30 | 1.1: {
31 | transform: {
32 | translate: "0%",
33 | translate2: "0vw",
34 | },
35 | },
36 | },
37 | "nav li": i => ({
38 | 0: {
39 | opacity: 0,
40 | transform: "translate(-50px)",
41 | },
42 | 0.3: {
43 | opacity: 1,
44 | transform: "translate(0px)",
45 | },
46 | options: {
47 | delay: 0.9 + i * 0.1,
48 | },
49 | }),
50 | }, {
51 | easing: Scene.EASE_IN_OUT,
52 | selector: true,
53 | }).on({
54 | play: () => {
55 | nav.style.display = "block";
56 | },
57 | ended: () => {
58 | if (navScene.getDirection() === "reverse") {
59 | nav.style.display = "none";
60 | } else {
61 | nav.style.display = "block";
62 | }
63 | },
64 | });
65 | function enterNav() {
66 | if (hasClass(body, "navigate") || (navScene.getPlayState() === "running" && navScene.getDirection() === "normal")) {
67 | return;
68 | }
69 | addClass(body, "navigate");
70 | navScene.pause();
71 | navScene.setPlaySpeed(1);
72 | navScene.setDirection("normal");
73 | navScene.setTime(0);
74 | navScene.play();
75 | }
76 | function exitNav() {
77 | if (!hasClass(body, "navigate") ||
78 | (navScene.getPlayState() === "running" && navScene.getDirection() === "reverse")) {
79 | return;
80 | }
81 | removeClass(body, "navigate");
82 | navScene.pause();
83 | navScene.setPlaySpeed(1.5);
84 | navScene.setDirection("reverse");
85 | navScene.setTime(0);
86 | navScene.play();
87 | }
88 | toArray(menus).forEach((menu, i) => {
89 | const page = pages[i];
90 |
91 | page.range(["window - 1", "window"]).on({
92 | enter: e => {
93 | addClass(menu, "enter");
94 | },
95 | exit: e => {
96 | removeClass(menu, "enter");
97 | },
98 | });
99 | menu.addEventListener("click", e => {
100 | e.preventDefault();
101 | scroll(page.getRect(true).top);
102 | exitNav();
103 | });
104 | });
105 | $("header .logo").addEventListener("click", e => {
106 | e.preventDefault();
107 | scroll(pages[0].getRect(true).top);
108 | exitNav();
109 | });
110 | addEvent(nav, "click", e => {
111 | if (e.target === nav) {
112 | exitNav();
113 | }
114 | });
115 | addEvent(navButon, "click", () => {
116 | if (hasClass(body, "navigate")) {
117 | exitNav();
118 | } else {
119 | enterNav();
120 | }
121 | });
122 |
123 |
124 | pages.forEach((page, i) => {
125 | if (i % 2 === 0) {
126 | return;
127 | }
128 | page.range(["window - 80", "100% - 80"]).on({
129 | enter: e => {
130 | addClass(body, "white");
131 | },
132 | exit: e => {
133 | removeClass(body, "white");
134 | },
135 | });
136 | });
137 |
--------------------------------------------------------------------------------
/packages/demo/src/index/StartedPage.ts:
--------------------------------------------------------------------------------
1 | import Page from "@daybrush/page";
2 | import { add } from "./Store";
3 |
4 | const page4 = new Page(".page.page4");
5 |
6 | add(page4);
7 |
--------------------------------------------------------------------------------
/packages/demo/src/index/Store.ts:
--------------------------------------------------------------------------------
1 | import Page from "@daybrush/page";
2 |
3 | export const manager = new Page.s({
4 | events: ["resize", "scroll"],
5 | });
6 | export const pages: Page[] = [];
7 | export function add(page: Page) {
8 | pages.push(page);
9 | manager.add(page);
10 | }
11 | export function scroll() {
12 | manager.scroll();
13 | }
14 |
--------------------------------------------------------------------------------
/packages/demo/src/index/css/page3.css:
--------------------------------------------------------------------------------
1 | .page3 {
2 | min-height: 1200px;
3 | }
4 | .page3 .examples {
5 | list-style: none;
6 | padding: 0;
7 | margin: 0;
8 | padding-top: 30px;
9 | text-align: center;
10 | }
11 | .page3 .examples li {
12 | display: inline-block;
13 | width: 30%;
14 | margin: 0;
15 | font-size: 15px;
16 | transition: transform ease 0.2s;
17 | text-align: center;
18 | vertical-align: top;
19 | box-sizing: border-box;
20 | }
21 | .page3 .examples li a {
22 | position: relative;
23 | margin: 10px;
24 | display: block;
25 | text-align: center;
26 | overflow: hidden;
27 | max-height: 260px;
28 | }
29 | .page3 .examples li a:after {
30 | content: "";
31 | position: relative;
32 | display: block;
33 | width: 100%;
34 | padding-top: 75%;
35 | }
36 | .page3 .examples li a img {
37 | position: absolute;
38 | display: inline-block;
39 | width: 100%;
40 | max-width: 300px;
41 | top: -100px;
42 | left: 0;
43 | right: 0;
44 | bottom: -100px;
45 | margin: auto;
46 |
47 | }
48 | .page3 .more_area {
49 | text-align: center;
50 | padding-top: 30px;
51 | }
52 | .page3 .more_area .more {
53 | padding: 15px;
54 | border: 2px solid #333;
55 | background: transparent;
56 | font-weight: bold;
57 | font-size: 16px;
58 | cursor: pointer;
59 | }
60 |
61 | @media screen and (max-width: 800px) {
62 | .page.page3 {
63 | min-height: 1650px;
64 | }
65 | .page3 .examples li {
66 | width: 49%;
67 | }
68 | }
69 | @media screen and (max-width: 600px) {
70 | .page3 .examples li {
71 | width: 99%;
72 | }
73 | .page.page3 {
74 | height: auto;
75 | }
76 | .page3 .container {
77 | top: 0;
78 | transform: none;
79 | }
80 | }
--------------------------------------------------------------------------------
/packages/demo/src/index/css/page4.css:
--------------------------------------------------------------------------------
1 | .page4 {
2 | min-height: 850px;
3 | }
4 | .page4 .container {
5 |
6 | }
7 | .page4 p {
8 | text-align: center;
9 | padding: 15px 0px;
10 | }
--------------------------------------------------------------------------------
/packages/demo/src/index/index.ts:
--------------------------------------------------------------------------------
1 | import "./MainPage";
2 | import "./FeaturesPage";
3 | import "./ExamplesPage";
4 | import "./StartedPage";
5 | import "./Header";
6 | import { scroll } from "./Store";
7 | import "./css/index.css";
8 | import "./css/page1.css";
9 | import "./css/page2.css";
10 | import "./css/page3.css";
11 | import "./css/page4.css";
12 |
13 | scroll();
14 |
--------------------------------------------------------------------------------
/packages/demo/src/index/utils.ts:
--------------------------------------------------------------------------------
1 | import NativeScene, {animateItem, EasingFunction} from "scenejs";
2 |
3 | declare var Scene: typeof NativeScene & {
4 | animateItem: typeof animateItem,
5 | EASE: EasingFunction,
6 | };
7 |
8 | export function scroll(to: number) {
9 | return Scene.animateItem({
10 | scrollTop: [document.documentElement.scrollTop || document.body.scrollTop, to],
11 | }, {
12 | duration: 1,
13 | easing: Scene.EASE,
14 | }).on("animate", ({frame}) => {
15 | window.scrollTo(0, frame.get("scrollTop"));
16 | });
17 | }
18 |
--------------------------------------------------------------------------------
/packages/demo/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "outDir": "./outjs/",
4 | "esModuleInterop": false,
5 | "sourceMap": true,
6 | "module": "es2015",
7 | "target": "es5",
8 | "experimentalDecorators": true,
9 | "skipLibCheck": true,
10 | "moduleResolution": "node",
11 | "lib": [
12 | "es2015",
13 | "dom"
14 | ],
15 | },
16 | "include": [
17 | "./src/**/*.ts"
18 | ]
19 | }
--------------------------------------------------------------------------------
/packages/react-scenejs/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/packages/react-scenejs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-scenejs",
3 | "version": "2.0.0-beta.14",
4 | "lernaHelperReleaseType": "prerelease",
5 | "lernaHelperPublishTag": "latest",
6 | "description": "A React Component that create JavaScript & CSS timeline-based animation with Scene.js.",
7 | "main": "./dist/scene.cjs.js",
8 | "module": "./dist/scene.esm.js",
9 | "sideEffects": false,
10 | "types": "declaration/index.d.ts",
11 | "keywords": [
12 | "react",
13 | "reactive",
14 | "hooks",
15 | "use",
16 | "scene",
17 | "scene.js",
18 | "scenejs",
19 | "keyframes",
20 | "timeline",
21 | "animate",
22 | "animation",
23 | "css",
24 | "requestAnimationFrame",
25 | "motion"
26 | ],
27 | "repository": {
28 | "type": "git",
29 | "url": "https://github.com/daybrush/scenejs.git"
30 | },
31 | "author": "Daybrush",
32 | "license": "MIT",
33 | "bugs": {
34 | "url": "https://github.com/daybrush/scenejs/issues"
35 | },
36 | "homepage": "https://daybrush.com/scenejs",
37 | "files": [
38 | "./*",
39 | "dist/*",
40 | "declaration/*"
41 | ],
42 | "dependencies": {
43 | "@cfcs/react": "^0.1.0",
44 | "scenejs": "~1.10.3"
45 | },
46 | "scripts": {
47 | "start": "rm -rf ./node_modules/.cache && react-scripts start",
48 | "build": "rollup -c && npm run declaration",
49 | "declaration": "rm -rf declaration && tsc -p tsconfig.declaration.json",
50 | "test": "react-scripts test",
51 | "eject": "react-scripts eject"
52 | },
53 | "eslintConfig": {
54 | "extends": [
55 | "react-app",
56 | "react-app/jest"
57 | ]
58 | },
59 | "browserslist": {
60 | "production": [
61 | ">0.2%",
62 | "not dead",
63 | "not op_mini all"
64 | ],
65 | "development": [
66 | "last 1 chrome version",
67 | "last 1 firefox version",
68 | "last 1 safari version"
69 | ]
70 | },
71 | "devDependencies": {
72 | "@daybrush/builder": "^0.2.0",
73 | "@testing-library/jest-dom": "^5.16.5",
74 | "@testing-library/react": "^13.4.0",
75 | "@testing-library/user-event": "^13.5.0",
76 | "@types/jest": "^27.5.2",
77 | "@types/node": "^16.18.9",
78 | "@types/react": "^18.0.26",
79 | "@types/react-dom": "^18.0.9",
80 | "react": "^18.2.0",
81 | "react-dom": "^18.2.0",
82 | "react-scripts": "5.0.1",
83 | "typescript": "^4.5.0 <4.6.0",
84 | "web-vitals": "^2.1.4"
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/packages/react-scenejs/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | React App
28 |
29 |
30 | You need to enable JavaScript to run this app.
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/packages/react-scenejs/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/packages/react-scenejs/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/packages/react-scenejs/rollup.config.js:
--------------------------------------------------------------------------------
1 | const builder = require("@daybrush/builder");
2 |
3 | const defaultOptions = {
4 | tsconfig: "tsconfig.build.json",
5 | };
6 |
7 | module.exports = builder([
8 | {
9 | ...defaultOptions,
10 | input: "src/react-scenejs/index.tsx",
11 | output: "./dist/scene.esm.js",
12 | visualizer: true,
13 | format: "es",
14 | exports: "named",
15 | },
16 | {
17 | ...defaultOptions,
18 | input: "src/react-scenejs/index.tsx",
19 | output: "./dist/scene.cjs.js",
20 | format: "cjs",
21 | exports: "named",
22 | },
23 | ]);
24 |
--------------------------------------------------------------------------------
/packages/react-scenejs/src/App.css:
--------------------------------------------------------------------------------
1 | html, body, #root, .root, .App {
2 | position: relative;
3 | height: 100%;
4 | }
5 | .motion {
6 | position: absolute;
7 | left: 0;
8 | right: 0;
9 | top: 0;
10 | bottom: 0;
11 | width: 200px;
12 | height: 200px;
13 | margin: auto;
14 | }
15 |
16 | .star {
17 | position: absolute;
18 | left: 0;
19 | right: 0;
20 | top: 0;
21 | width: 20px;
22 | height: 20px;
23 | margin: auto;
24 | }
25 |
26 | .star::before {
27 | content: "";
28 | position: absolute;
29 | width: 100%;
30 | height: 100%;
31 | bottom: 50%;
32 | right: 50%;
33 | border: 8px solid #5a5;
34 | border-bottom: 0;
35 | border-right: 0;
36 | transform: skew(9deg, 9deg);
37 | transform-origin: 100% 100%;
38 | }
39 |
40 | .star>.star {
41 | transform: rotate(72deg);
42 | }
43 |
44 | .triangle {
45 | position: absolute;
46 | left: 0;
47 | right: 0;
48 | top: 0px;
49 | bottom: 20px;
50 | margin: auto;
51 | width: 100px;
52 | height: 10px;
53 | border-radius: 5px;
54 | background: #f5f;
55 | }
56 |
57 | .triangle:before,
58 | .triangle:after {
59 | content: "";
60 | position: absolute;
61 | width: 100%;
62 | height: 100%;
63 | border-radius: inherit;
64 | background: inherit;
65 | }
66 |
67 | .triangle:before {
68 | transform-origin: 5px 50%;
69 | transform: rotate(60deg);
70 | }
71 |
72 | .triangle:after {
73 | transform-origin: calc(100% - 5px) 50%;
74 | transform: rotate(-60deg);
75 | }
76 |
77 | .rectangle {
78 | position: absolute;
79 | left: 0;
80 | right: 0;
81 | top: 0;
82 | bottom: 0;
83 | margin: auto;
84 | width: 80px;
85 | height: 80px;
86 | border-radius: 5px;
87 | border: 10px solid #f55;
88 | }
89 |
90 | .circle {
91 | position: absolute;
92 | width: 140px;
93 | height: 140px;
94 | border-radius: 50%;
95 | box-sizing: border-box;
96 | border: 70px solid #5ff;
97 | left: 0;
98 | right: 0;
99 | top: -20px;
100 | bottom: -20px;
101 | margin: auto;
102 | }
103 |
104 | .rectangle2 {
105 | border-color: #55f;
106 | }
107 |
108 | .circle2 {
109 | width: 40px;
110 | height: 40px;
111 | bottom: 20px;
112 | border: 8px solid #EED414;
113 | }
114 |
115 | .star1 {
116 | top: 0;
117 | bottom: 20px;
118 | }
119 | .raindrop {
120 | position: absolute;
121 | width: 300px;
122 | height: 300px;
123 | left: 0;
124 | right: 0;
125 | top: 0;
126 | bottom: 0;
127 | margin: auto;
128 | border: 100px solid black;
129 | border-radius: 50%;
130 | box-sizing: border-box;
131 | transform: scale(0);
132 | }
133 |
--------------------------------------------------------------------------------
/packages/react-scenejs/src/App.test.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { render, screen } from '@testing-library/react';
3 | import App from './App';
4 |
5 | test('renders learn react link', () => {
6 | render( );
7 | const linkElement = screen.getByText(/learn react/i);
8 | expect(linkElement).toBeInTheDocument();
9 | });
10 |
--------------------------------------------------------------------------------
/packages/react-scenejs/src/App.tsx:
--------------------------------------------------------------------------------
1 | import { useEffect } from 'react';
2 | import './App.css';
3 | import { useScene } from './react-scenejs/useScene';
4 | import { selectorAll } from 'scenejs';
5 |
6 |
7 | export default function App() {
8 | const scene = useScene(
9 | {
10 | ".raindrop": selectorAll(
11 | (i) => ({
12 | 0: { "border-width": "150px", opacity: 1, transform: "scale(0)" },
13 | 1.5: { "border-width": "0px", opacity: 0.3, transform: "scale(0.7)" },
14 | options: { delay: i * 0.4 }
15 | }),
16 | 3
17 | )
18 | },
19 | {
20 | selector: true,
21 | easing: "ease-in-out",
22 | iterationCount: "infinite"
23 | }
24 | );
25 |
26 | useEffect(() => {
27 | scene.play();
28 |
29 | return () => {
30 | scene.finish();
31 | };
32 | }, []);
33 |
34 | return (
35 |
40 | );
41 | }
42 |
--------------------------------------------------------------------------------
/packages/react-scenejs/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/packages/react-scenejs/src/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom/client';
3 | import './index.css';
4 | import App from './App';
5 | import reportWebVitals from './reportWebVitals';
6 |
7 | const root = ReactDOM.createRoot(
8 | document.getElementById('root') as HTMLElement
9 | );
10 | root.render(
11 |
12 |
13 |
14 | );
15 |
16 | // If you want to start measuring performance in your app, pass a function
17 | // to log results (for example: reportWebVitals(console.log))
18 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
19 | reportWebVitals();
20 |
--------------------------------------------------------------------------------
/packages/react-scenejs/src/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/react-scenejs/src/react-app-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/packages/react-scenejs/src/react-scenejs/index.tsx:
--------------------------------------------------------------------------------
1 | /**
2 | * @namespace ReactScene
3 | */
4 | export * from "./useScene";
5 | export * from "./useSceneItem";
6 | export * from "./useFrame";
7 | export * from "./useNowFrame";
8 | export * from "scenejs";
--------------------------------------------------------------------------------
/packages/react-scenejs/src/react-scenejs/useFrame.tsx:
--------------------------------------------------------------------------------
1 | import { ReactReactiveAdapterResult, useReactive } from "@cfcs/react";
2 | import { FRAME_REACTIVE, FrameReactiveData } from "scenejs";
3 |
4 |
5 | /**
6 | * You can use reactive state and frame methods.
7 | * @typedef
8 | * @memberof ReactScene
9 | * @see Frame
10 | * @extends Reactive.FrameReactiveState
11 | */
12 | export interface ReactFrameResult extends ReactReactiveAdapterResult { }
13 |
14 | /**
15 | * @memberof ReactScene
16 | * @param {Reactive.FrameReactiveData} - Can be used as frame, cssText, cssObject, etc.
17 | * @return - You can use Frame methods and cssText, cssObject, ...etc
18 | * @example
19 | * import { useFrame } from "react-scenejs";
20 | *
21 | * const frame = useFrame("text-align: center; transform: translate(10px, 10px);");
22 | *
23 | * frame.camelCasedCSSObject;
24 | */
25 | export function useFrame(props: FrameReactiveData): ReactFrameResult {
26 | return useReactive({
27 | ...FRAME_REACTIVE,
28 | data: () => props,
29 | });
30 | }
31 |
--------------------------------------------------------------------------------
/packages/react-scenejs/src/react-scenejs/useNowFrame.tsx:
--------------------------------------------------------------------------------
1 | import { ReactReactiveAdapterResult, useReactive } from "@cfcs/react";
2 | import { SceneItem, NOW_FRAME_REACTIVE } from "scenejs";
3 |
4 |
5 | /**
6 | * @typedef
7 | * @memberof ReactScene
8 | * @extends ReactScene.ReactFrameResult
9 | */
10 | export interface ReactNowFrameResult extends ReactReactiveAdapterResult { }
11 |
12 | /**
13 | * @memberof ReactScene
14 | * @param - item to get the current frame
15 | * @return - You can use Frame methods and cssText, cssObject, ...etc State
16 | * @example
17 | * import { useSceneItem, useNowFrame } from "react-scenejs";
18 | *
19 | * const sceneItem = useSceneItem(...);
20 | * const frame = useNowFrame(sceneItem);
21 | *
22 | * frame.camelCasedCSSObject;
23 | */
24 | export function useNowFrame(item: SceneItem): ReactNowFrameResult {
25 | return useReactive({
26 | ...NOW_FRAME_REACTIVE,
27 | data: () => item,
28 | });
29 | }
--------------------------------------------------------------------------------
/packages/react-scenejs/src/react-scenejs/useScene.tsx:
--------------------------------------------------------------------------------
1 | import { ReactReactiveAdapterResult, useReactive } from "@cfcs/react";
2 | import { SceneOptions, SceneReactiveProps, SCENE_REACTIVE } from "scenejs";
3 |
4 |
5 | /**
6 | * @typedef
7 | * @memberof ReactScene
8 | * @extends Reactive.AnimatorReactiveState
9 | */
10 | export interface ReactSceneResult extends ReactReactiveAdapterResult { }
11 |
12 |
13 | /**
14 | * @memberof ReactScene
15 | * @param {Reactive.SceneReactiveProps} - Items and properties that make up the scene
16 | * @param - Scene and Animator options
17 | * @return - You can use Scene methods and Animator State
18 | * @example
19 | * import { useScene, useNowFrame } from "react-scenejs";
20 | *
21 | * const scene = useScene({ ... });
22 | * const frame = useNowFrame(scene.getItem("a1"));
23 | *
24 | * frame.camelCasedCSSObject;
25 | */
26 | export function useScene(props?: SceneReactiveProps, options?: Partial): ReactSceneResult {
27 | return useReactive({
28 | ...SCENE_REACTIVE,
29 | data() {
30 | return {
31 | props,
32 | options,
33 | };
34 | },
35 | });
36 | }
--------------------------------------------------------------------------------
/packages/react-scenejs/src/react-scenejs/useSceneItem.tsx:
--------------------------------------------------------------------------------
1 | import { ReactReactiveAdapterResult, useReactive } from "@cfcs/react";
2 | import { SCENE_ITEM_REACTIVE, SceneItemOptions, SceneItemReactiveProps } from "scenejs";
3 |
4 | /**
5 | * @typedef
6 | * @memberof ReactScene
7 | * @extends Reactive.AnimatorReactiveState
8 | */
9 | export interface ReactSceneItemResult extends ReactReactiveAdapterResult { }
10 |
11 | /**
12 | * @memberof ReactScene
13 | * @param {Reactive.SceneItemReactiveProps} - Items and properties that make up the scene item
14 | * @param - SceneItem and Animator options
15 | * @return - You can use SceneItem methods and Animator State.
16 | * @example
17 | * import { useSceneItem, useNowFrame } from "react-scenejs";
18 | *
19 | * const item = useSceneItem({ ... });
20 | * const frame = useNowFrame(item);
21 | *
22 | * frame.camelCasedCSSObject;
23 | */
24 | export function useSceneItem(props?: SceneItemReactiveProps, options?: Partial) {
25 | return useReactive({
26 | ...SCENE_ITEM_REACTIVE,
27 | data: () => ({
28 | props,
29 | options,
30 | }),
31 | });
32 | }
--------------------------------------------------------------------------------
/packages/react-scenejs/src/reportWebVitals.ts:
--------------------------------------------------------------------------------
1 | import { ReportHandler } from 'web-vitals';
2 |
3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => {
4 | if (onPerfEntry && onPerfEntry instanceof Function) {
5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
6 | getCLS(onPerfEntry);
7 | getFID(onPerfEntry);
8 | getFCP(onPerfEntry);
9 | getLCP(onPerfEntry);
10 | getTTFB(onPerfEntry);
11 | });
12 | }
13 | };
14 |
15 | export default reportWebVitals;
16 |
--------------------------------------------------------------------------------
/packages/react-scenejs/src/setupTests.ts:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/packages/react-scenejs/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig",
3 | "compilerOptions": {
4 | "jsx": "react"
5 | },
6 | }
7 |
--------------------------------------------------------------------------------
/packages/react-scenejs/tsconfig.declaration.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig",
3 | "compilerOptions": {
4 | "allowJs": false,
5 | "noEmit": false,
6 | "isolatedModules": false,
7 | "removeComments": false,
8 | "declaration": true,
9 | "emitDeclarationOnly": true,
10 | "declarationDir": "declaration"
11 | },
12 | "include": [
13 | "./src/react-scenejs/*"
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/packages/react-scenejs/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": [
5 | "dom",
6 | "dom.iterable",
7 | "esnext"
8 | ],
9 | "allowJs": true,
10 | "skipLibCheck": true,
11 | "esModuleInterop": true,
12 | "allowSyntheticDefaultImports": true,
13 | "strict": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "noFallthroughCasesInSwitch": true,
16 | "module": "esnext",
17 | "moduleResolution": "node",
18 | "resolveJsonModule": true,
19 | "isolatedModules": true,
20 | "noEmit": true,
21 | "jsx": "react-jsx"
22 | },
23 | "include": [
24 | "src"
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/packages/scenejs/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [{*.js,*.ts}]
5 | charset = utf-8
6 | end_of_line = lf
7 | indent_style = space
8 | indent_size = 4
9 | insert_final_newline = true
10 | max_line_length = 80
11 | trim_trailing_whitespace = true
12 |
13 | [{package.json,.travis.yml}]
14 | indent_style = space
15 | indent_size = 4
--------------------------------------------------------------------------------
/packages/scenejs/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | *.DS_Store
3 | .DS_Store
4 | doc/
5 | dist/
6 | packages/*/dist
7 | demo/dist/
8 | release/
9 | npm-debug.log*
10 | coverage/
11 | jsdoc/
12 | doc/
13 | outjs/
14 | declaration/
15 | build/
16 | .vscode/
17 | rollup-plugin-visualizer/
18 | statistics/
19 | .scene_cache
20 | *.mp4
--------------------------------------------------------------------------------
/packages/scenejs/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | *.DS_Store
3 | .DS_Store
4 | doc/
5 | template/
6 | example/
7 | karma.conf.js
8 | test/
9 | mocha.opts
10 | Gruntfile.js
11 | webpack.*.js
12 | .travis.yml
13 | packages
14 | release/
15 | demo/
16 | coverage/
17 | dist/report.html
18 | rollup-plugin-visualizer/
19 | outjs/
20 | statistics/
21 | .scene_cache
22 | *.mp3
23 | *.mp4
24 | ./examples
--------------------------------------------------------------------------------
/packages/scenejs/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - stable
4 | install:
5 | - npm install
6 | script:
7 | - npm run coverage
8 | cache:
9 | directories:
10 | - node_modules
11 | after_success:
12 | - npm run coveralls
--------------------------------------------------------------------------------
/packages/scenejs/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Daybrush
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/scenejs/karma.conf.js:
--------------------------------------------------------------------------------
1 | module.exports = function (config) {
2 | const karmaConfig = {
3 | frameworks: ["mocha", "chai", "karma-typescript"],
4 | mime: {
5 | 'text/x-typescript': ['ts', 'tsx']
6 | },
7 | client: {
8 | mocha: {
9 | opts: "./mocha.opts",
10 | },
11 | },
12 | files: [
13 | "./src/**/*.ts",
14 | "./test/unit/**/*.ts",
15 | ],
16 | preprocessors: {
17 | "src/**/*.ts": ["karma-typescript"],
18 | "test/unit/**/*.ts": ["karma-typescript"],
19 | },
20 | karmaTypescriptConfig: {
21 | tsconfig: "./tsconfig.test.json",
22 | reports: {
23 | html: {
24 | "directory": "coverage",
25 | "subdirectory": "./"
26 | },
27 | lcovonly: {
28 | "directory": "coverage",
29 | "filename": "lcov.info",
30 | "subdirectory": "."
31 | },
32 | },
33 | coverageOptions: {
34 | instrumentation: true,
35 | exclude: /test/i,
36 | }
37 | },
38 | browsers: [],
39 | customLaunchers: {
40 | CustomChromeHeadless: {
41 | base: "ChromeHeadless",
42 | flags: ["--window-size=400,400", "--no-sandbox", "--disable-setuid-sandbox"],
43 | },
44 | },
45 | reporters: ["mocha"],
46 | };
47 |
48 | karmaConfig.browsers.push(config.chrome ? "Chrome" : "CustomChromeHeadless");
49 |
50 | if (config.coverage) {
51 | karmaConfig.reporters.push("karma-typescript");
52 | karmaConfig.singleRun = true;
53 | }
54 |
55 | config.set(karmaConfig);
56 | };
57 |
--------------------------------------------------------------------------------
/packages/scenejs/mocha.opts:
--------------------------------------------------------------------------------
1 | --timeout 10000
--------------------------------------------------------------------------------
/packages/scenejs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "scenejs",
3 | "version": "1.10.3",
4 | "description": "JavaScript & CSS timeline-based animation library",
5 | "main": "dist/scene.cjs.js",
6 | "module": "dist/scene.esm.js",
7 | "sideEffects": false,
8 | "types": "declaration/index.d.ts",
9 | "scripts": {
10 | "lint": "tslint -c tslint.json 'src/**/*.ts'",
11 | "coverage": "karma start --coverage && print-coveralls --sort=desc",
12 | "test": "karma start",
13 | "start": "rollup -c -w",
14 | "test:chrome": "karma start --chrome",
15 | "build": "rollup -c && print-sizes ./dist && npm run declaration && npm run lint",
16 | "declaration": "tsc -p tsconfig.declaration.json",
17 | "coveralls": "cat ./coverage/lcov.info | coveralls"
18 | },
19 | "repository": {
20 | "type": "git",
21 | "url": "https://github.com/daybrush/scenejs.git"
22 | },
23 | "keywords": [
24 | "scene",
25 | "scene.js",
26 | "scenejs",
27 | "keyframes",
28 | "timeline",
29 | "animate",
30 | "animation",
31 | "css",
32 | "requestAnimationFrame",
33 | "motion"
34 | ],
35 | "author": "Daybrush",
36 | "license": "MIT",
37 | "bugs": {
38 | "url": "https://github.com/daybrush/scenejs/issues"
39 | },
40 | "homepage": "https://daybrush.com/scenejs",
41 | "files": [
42 | "./*",
43 | "dist/*",
44 | "declaration/*"
45 | ],
46 | "devDependencies": {
47 | "@daybrush/builder": "^0.2.0",
48 | "@types/chai": "^4.1.7",
49 | "@types/karma-chai": "^0.1.1",
50 | "@types/mocha": "^5.2.6",
51 | "@types/node": "^18.11.17",
52 | "@types/sinon": "^10.0.11",
53 | "chai": "^4.2.0",
54 | "coveralls": "^3.0.0",
55 | "karma": "^4.0.1",
56 | "karma-chai": "^0.1.0",
57 | "karma-chrome-launcher": "^2.2.0",
58 | "karma-mocha": "^1.3.0",
59 | "karma-mocha-reporter": "^2.2.5",
60 | "karma-typescript": "^5.5.3",
61 | "mocha": "^6.0.2",
62 | "print-coveralls": "^1.2.2",
63 | "print-sizes": "^0.2.0",
64 | "sinon": "^4.1.2",
65 | "tslib": "^2.4.1",
66 | "tslint": "^5.14.0",
67 | "typescript": "^4.5.0 <4.6.0"
68 | },
69 | "dependencies": {
70 | "@cfcs/core": "^0.1.0",
71 | "@daybrush/utils": "^1.10.2",
72 | "@scena/event-emitter": "^1.0.3",
73 | "css-styled": "^1.0.6",
74 | "order-map": "^0.3.1"
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/packages/scenejs/rollup.config.demo.js:
--------------------------------------------------------------------------------
1 | import builder from "@daybrush/builder";
2 | import cssbundle from "rollup-plugin-css-bundle";
3 |
4 | export default builder([
5 | {
6 | input: 'demo/src/index/index.ts',
7 | output: "./demo/dist/index.js",
8 | format: "iife",
9 | exports: "named",
10 | plugins: [cssbundle({output: "./demo/dist/index.css"})],
11 | resolve: true,
12 | uglify: true,
13 | },
14 | {
15 | input: 'demo/src/features/index.ts',
16 | output: "./demo/dist/features.js",
17 | format: "iife",
18 | exports: "named",
19 | plugins: [cssbundle({output: "./demo/dist/features.css"})],
20 | resolve: true,
21 | uglify: true,
22 | },
23 | ]);
24 |
--------------------------------------------------------------------------------
/packages/scenejs/rollup.config.js:
--------------------------------------------------------------------------------
1 | const builder = require("@daybrush/builder");
2 |
3 | const external = {
4 | "@daybrush/utils": "utils",
5 | "list-map": "ListMap",
6 | }
7 | module.exports = builder([
8 | {
9 | input: 'src/index.ts',
10 | output: "./dist/scene.esm.js",
11 | format: "es",
12 | exports: "named",
13 | external,
14 | },
15 | {
16 | input: 'src/index.cjs.ts',
17 | output: "./dist/scene.cjs.js",
18 | format: "cjs",
19 | exports: "named",
20 | external,
21 | },
22 | {
23 | name: "Scene",
24 | input: "src/index.umd.ts",
25 | output: "./dist/scene.js",
26 | resolve: true,
27 | },
28 | {
29 | name: "Scene",
30 | input: "src/index.umd.ts",
31 | output: "./dist/scene.min.js",
32 | resolve: true,
33 | uglify: true,
34 | visualizer: {},
35 | }
36 | ]);
37 |
--------------------------------------------------------------------------------
/packages/scenejs/src/PropertyObject.ts:
--------------------------------------------------------------------------------
1 | import { isString } from "@daybrush/utils";
2 | import { PropertyObjectState } from "./types";
3 | import { isPropertyObject } from "./utils";
4 |
5 | /**
6 | * Make string, array to PropertyObject for the dot product
7 | */
8 | class PropertyObject implements PropertyObjectState {
9 | public value: any[];
10 | public prefix: string = "";
11 | public suffix: string = "";
12 | public model: string = "";
13 | public type: string = "";
14 | public separator: string = ",";
15 |
16 | /**
17 | * @param - This value is in the array format.
18 | * @param - options
19 | * @example
20 | var obj = new PropertyObject([100,100,100,0.5], {
21 | "separator" : ",",
22 | "prefix" : "rgba(",
23 | "suffix" : ")"
24 | });
25 | */
26 | constructor(value: string | any[], options?: Partial) {
27 | options && this.setOptions(options);
28 | this.value = isString(value) ? value.split(this.separator) : value;
29 | }
30 | public setOptions(newOptions: Partial) {
31 | for (const name in newOptions) {
32 | this[name as keyof PropertyObjectState] = newOptions[name as keyof PropertyObjectState];
33 | }
34 | return this;
35 | }
36 | /**
37 | * the number of values.
38 | * @example
39 | const obj1 = new PropertyObject("1,2,3", ",");
40 |
41 | console.log(obj1.length);
42 | // 3
43 | */
44 | public size() {
45 | return this.value.length;
46 | }
47 | /**
48 | * retrieve one of values at the index
49 | * @param {Number} index - index
50 | * @return {Object} one of values at the index
51 | * @example
52 | const obj1 = new PropertyObject("1,2,3", ",");
53 |
54 | console.log(obj1.get(0));
55 | // 1
56 | */
57 | public get(index: number) {
58 | return this.value[index];
59 | }
60 | /**
61 | * Set the value at that index
62 | * @param {Number} index - index
63 | * @param {Object} value - text, a number, object to set
64 | * @return {PropertyObject} An instance itself
65 | * @example
66 | const obj1 = new PropertyObject("1,2,3", ",");
67 | obj1.set(0, 2);
68 | console.log(obj1.toValue());
69 | // 2,2,3
70 | */
71 | public set(index: number, value: any) {
72 | this.value[index] = value;
73 | return this;
74 | }
75 | /**
76 | * create a copy of an instance itself.
77 | * @return {PropertyObject} clone
78 | * @example
79 | const obj1 = new PropertyObject("1,2,3", ",");
80 | const obj2 = obj1.clone();
81 | */
82 | public clone(): PropertyObject {
83 | const {
84 | separator,
85 | prefix,
86 | suffix,
87 | model,
88 | type,
89 | } = this;
90 | const arr = this.value.map(v => (isPropertyObject(v) ? v.clone() : v));
91 | return new PropertyObject(arr, {
92 | separator,
93 | prefix,
94 | suffix,
95 | model,
96 | type,
97 | });
98 | }
99 | /**
100 | * Make Property Object to String
101 | * @return {String} Make Property Object to String
102 | * @example
103 | //rgba(100, 100, 100, 0.5)
104 | const obj4 = new PropertyObject([100,100,100,0.5], {
105 | "separator" : ",",
106 | "prefix" : "rgba(",
107 | "suffix" : ")",
108 | });
109 | console.log(obj4.toValue());
110 | // "rgba(100,100,100,0.5)"
111 | */
112 | public toValue(): string {
113 | return this.prefix + this.join() + this.suffix;
114 | }
115 | /**
116 | * Make Property Object's array to String
117 | * @return {String} Join the elements of an array into a string
118 | * @example
119 | //rgba(100, 100, 100, 0.5)
120 | var obj4 = new PropertyObject([100,100,100,0.5], {
121 | "separator" : ",",
122 | "prefix" : "rgba(",
123 | "suffix" : ")"
124 | });
125 | obj4.join(); // => "100,100,100,0.5"
126 | */
127 | public join() {
128 | return this.value.map(v => (isPropertyObject(v) ? v.toValue() : v)).join(this.separator);
129 | }
130 | /**
131 | * executes a provided function once per array element.
132 | * @param {Function} callback - Function to execute for each element, taking three arguments
133 | * @param {All} [callback.currentValue] The current element being processed in the array.
134 | * @param {Number} [callback.index] The index of the current element being processed in the array.
135 | * @param {Array} [callback.array] the array.
136 | * @return {PropertyObject} An instance itself
137 | * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach|MDN Array.forEach()} reference to MDN document.
138 | * @example
139 | //rgba(100, 100, 100, 0.5)
140 | var obj4 = new PropertyObject([100,100,100,0.5], {
141 | "separator" : ",",
142 | "prefix" : "rgba(",
143 | "suffix" : ")"
144 | });
145 |
146 | obj4.forEach(t => {
147 | console.log(t);
148 | }); // => "100,100,100,0.5"
149 | */
150 | public forEach(func: (value?: any, index?: number, array?: any[]) => void) {
151 | this.value.forEach(func);
152 | return this;
153 | }
154 | }
155 | export default PropertyObject;
156 |
--------------------------------------------------------------------------------
/packages/scenejs/src/consts.ts:
--------------------------------------------------------------------------------
1 | import { IObject } from "@daybrush/utils";
2 | import { RoleObject, OptionType, EventType, EasingFunction } from "./types";
3 | import { EASE, EASE_IN, EASE_IN_OUT, LINEAR, EASE_OUT, STEP_START, STEP_END } from "./easing";
4 |
5 | export const PREFIX = "__SCENEJS_";
6 | export const DATA_SCENE_ID = "data-scene-id";
7 | export const TIMING_FUNCTION = "animation-timing-function";
8 | export const ROLES: RoleObject = { transform: {}, filter: {}, attribute: {}, html: true };
9 | export const ALIAS: IObject = { easing: [TIMING_FUNCTION] };
10 | export const FIXED = { [TIMING_FUNCTION]: true, contents: true, html: true };
11 | export const MAXIMUM = 1000000;
12 | export const THRESHOLD = 0.000001;
13 |
14 | export const DURATION = "duration";
15 | export const FILL_MODE = "fillMode";
16 | export const DIRECTION = "direction";
17 | export const ITERATION_COUNT = "iterationCount";
18 | export const DELAY = "delay";
19 | export const EASING = "easing";
20 | export const PLAY_SPEED = "playSpeed";
21 | export const EASING_NAME = "easingName";
22 | export const ITERATION_TIME = "iterationTime";
23 | export const PAUSED = "paused";
24 | export const ENDED = "ended";
25 | export const TIMEUPDATE = "timeupdate";
26 | export const ANIMATE = "animate";
27 | export const PLAY = "play";
28 | export const RUNNING = "running";
29 | export const ITERATION = "iteration";
30 | export const START_ANIMATION = "startAnimation";
31 | export const PAUSE_ANIMATION = "pauseAnimation";
32 | export const ALTERNATE = "alternate";
33 | export const REVERSE = "reverse";
34 | export const ALTERNATE_REVERSE = "alternate-reverse";
35 | export const NORMAL = "normal";
36 | export const INFINITE = "infinite";
37 | export const PLAY_STATE = "playState";
38 | export const PLAY_CSS = "playCSS";
39 | export const PREV_TIME = "prevTime";
40 | export const TICK_TIME = "tickTime";
41 | export const CURRENT_TIME = "currentTime";
42 | export const SELECTOR = "selector";
43 | export const TRANSFORM_NAME = "transform";
44 | export const EASINGS = {
45 | "linear": LINEAR,
46 | "ease": EASE,
47 | "ease-in": EASE_IN,
48 | "ease-out": EASE_OUT,
49 | "ease-in-out": EASE_IN_OUT,
50 | "step-start": STEP_START,
51 | "step-end": STEP_END,
52 | };
53 | export const NAME_SEPARATOR = "_///_";
54 |
55 | /**
56 | * option name list
57 | * @name Scene.OPTIONS
58 | * @memberof Scene
59 | * @static
60 | * @type {$ts:OptionType}
61 | * @example
62 | * Scene.OPTIONS // ["duration", "fillMode", "direction", "iterationCount", "delay", "easing", "playSpeed"]
63 | */
64 | export const OPTIONS: OptionType = [DURATION, FILL_MODE, DIRECTION, ITERATION_COUNT, DELAY, EASING, PLAY_SPEED];
65 |
66 | /**
67 | * Event name list
68 | * @name Scene.EVENTS
69 | * @memberof Scene
70 | * @static
71 | * @type {$ts:EventType}
72 | * @example
73 | * Scene.EVENTS // ["paused", "ended", "timeupdate", "animate", "play", "iteration"];
74 | */
75 | export const EVENTS: EventType = [PAUSED, ENDED, TIMEUPDATE, ANIMATE, PLAY, ITERATION];
76 |
--------------------------------------------------------------------------------
/packages/scenejs/src/easing.ts:
--------------------------------------------------------------------------------
1 | import { between } from "@daybrush/utils";
2 | import { EasingFunction } from "./types";
3 |
4 | function cubic(y1: number, y2: number, t: number) {
5 | const t2 = 1 - t;
6 |
7 | // Bezier Curve Formula
8 | return t * t * t + 3 * t * t * t2 * y2 + 3 * t * t2 * t2 * y1;
9 | }
10 | function solveFromX(x1: number, x2: number, x: number) {
11 | // x 0 ~ 1
12 | // t 0 ~ 1
13 | let t = x;
14 | let solveX = x;
15 | let dx = 1;
16 |
17 | while (Math.abs(dx) > 1 / 1000) {
18 | // 예상 t초에 의한 _x값
19 | solveX = cubic(x1, x2, t);
20 | dx = solveX - x;
21 | // 차이가 미세하면 그 값을 t로 지정
22 | if (Math.abs(dx) < 1 / 1000) {
23 | return t;
24 | }
25 | t -= dx / 2;
26 | }
27 | return t;
28 | }
29 | /**
30 | * @namespace easing
31 | */
32 | /**
33 | * Cubic Bezier curve.
34 | * @memberof easing
35 | * @func bezier
36 | * @param {number} [x1] - point1's x
37 | * @param {number} [y1] - point1's y
38 | * @param {number} [x2] - point2's x
39 | * @param {number} [y2] - point2's y
40 | * @return {function} the curve function
41 | * @example
42 | import {bezier} from "scenejs";
43 | Scene.bezier(0, 0, 1, 1) // LINEAR
44 | Scene.bezier(0.25, 0.1, 0.25, 1) // EASE
45 | */
46 | export function bezier(x1: number, y1: number, x2: number, y2: number) {
47 | /*
48 | x = f(t)
49 | calculate inverse function by x
50 | t = f-1(x)
51 | */
52 | const func: EasingFunction = (x: number) => {
53 | const t = solveFromX(x1, x2, between(x, 0, 1));
54 |
55 | return cubic(y1, y2, t);
56 | };
57 |
58 | func.easingName = `cubic-bezier(${x1},${y1},${x2},${y2})`;
59 | return func;
60 | }
61 | /**
62 | * Specifies a stepping function
63 | * @see {@link https://www.w3schools.com/cssref/css3_pr_animation-timing-function.asp|CSS3 Timing Function}
64 | * @memberof easing
65 | * @func steps
66 | * @param {number} count - point1's x
67 | * @param {"start" | "end"} postion - point1's y
68 | * @return {function} the curve function
69 | * @example
70 | import {steps} from "scenejs";
71 | Scene.steps(1, "start") // Scene.STEP_START
72 | Scene.steps(1, "end") // Scene.STEP_END
73 | */
74 | export function steps(count: number, position: "start" | "end") {
75 | const func: EasingFunction = (time: number) => {
76 | const level = 1 / count;
77 |
78 | if (time >= 1) {
79 | return 1;
80 | }
81 | return (position === "start" ? level : 0) + Math.floor(time / level) * level;
82 | };
83 |
84 | func.easingName = `steps(${count}, ${position})`;
85 |
86 | return func;
87 | }
88 |
89 | /**
90 | * Equivalent to steps(1, start)
91 | * @memberof easing
92 | * @name STEP_START
93 | * @static
94 | * @type {function}
95 | * @example
96 | import {STEP_START} from "scenejs";
97 | Scene.STEP_START // steps(1, start)
98 | */
99 | export const STEP_START = /*#__PURE__#*/steps(1, "start");
100 | /**
101 | * Equivalent to steps(1, end)
102 | * @memberof easing
103 | * @name STEP_END
104 | * @static
105 | * @type {function}
106 | * @example
107 | import {STEP_END} from "scenejs";
108 | Scene.STEP_END // steps(1, end)
109 | */
110 | export const STEP_END = /*#__PURE__#*/steps(1, "end");
111 | /**
112 | * Linear Speed (0, 0, 1, 1)
113 | * @memberof easing
114 | * @name LINEAR
115 | * @static
116 | * @type {function}
117 | * @example
118 | import {LINEAR} from "scenejs";
119 | Scene.LINEAR
120 | */
121 | export const LINEAR = /*#__PURE__#*/bezier(0, 0, 1, 1);
122 | /**
123 | * Ease Speed (0.25, 0.1, 0.25, 1)
124 | * @memberof easing
125 | * @name EASE
126 | * @static
127 | * @type {function}
128 | * @example
129 | import {EASE} from "scenejs";
130 | Scene.EASE
131 | */
132 | export const EASE = /*#__PURE__#*/bezier(0.25, 0.1, 0.25, 1);
133 | /**
134 | * Ease In Speed (0.42, 0, 1, 1)
135 | * @memberof easing
136 | * @name EASE_IN
137 | * @static
138 | * @type {function}
139 | * @example
140 | import {EASE_IN} from "scenejs";
141 | Scene.EASE_IN
142 | */
143 | export const EASE_IN = /*#__PURE__#*/bezier(0.42, 0, 1, 1);
144 | /**
145 | * Ease Out Speed (0, 0, 0.58, 1)
146 | * @memberof easing
147 | * @name EASE_OUT
148 | * @static
149 | * @type {function}
150 | * @example
151 | import {EASE_OUT} from "scenejs";
152 | Scene.EASE_OUT
153 | */
154 | export const EASE_OUT = /*#__PURE__#*/bezier(0, 0, 0.58, 1);
155 | /**
156 | * Ease In Out Speed (0.42, 0, 0.58, 1)
157 | * @memberof easing
158 | * @name EASE_IN_OUT
159 | * @static
160 | * @type {function}
161 | * @example
162 | import {EASE_IN_OUT} from "scenejs";
163 | Scene.EASE_IN_OUT
164 | */
165 | export const EASE_IN_OUT = /*#__PURE__#*/bezier(0.42, 0, 0.58, 1);
166 |
--------------------------------------------------------------------------------
/packages/scenejs/src/index.cjs.ts:
--------------------------------------------------------------------------------
1 | import Scene, * as others from "./index";
2 |
3 | for (const name in others) {
4 | (Scene as any)[name] = (others as any)[name];
5 | }
6 | declare const module: any;
7 |
8 | export * from "./index";
9 | module.exports = Scene;
10 | export default Scene;
11 |
--------------------------------------------------------------------------------
/packages/scenejs/src/index.ts:
--------------------------------------------------------------------------------
1 | import Scene from "./Scene";
2 | import SceneItem from "./SceneItem";
3 | import Frame from "./Frame";
4 | import Animator from "./Animator";
5 |
6 | export { Scene, SceneItem, Frame, Animator };
7 | export * from "./easing";
8 | export * from "./presets";
9 | export * from "./types";
10 | export { OPTIONS, EVENTS, FIXED, ROLES, NAME_SEPARATOR } from "./consts";
11 | export {
12 | setRole, setAlias, isRole,
13 | isScene, isSceneItem,
14 | isAnimator,
15 | isFrame, selectorAll,
16 | rgbaToHexWithOpacity,
17 | rgbaToHexa,
18 | } from "./utils";
19 | export { Scene as default };
20 | export * from "./reactive";
21 |
--------------------------------------------------------------------------------
/packages/scenejs/src/index.umd.ts:
--------------------------------------------------------------------------------
1 | import Scene, * as others from "./index";
2 |
3 | for (const name in others) {
4 | (Scene as any)[name] = (others as any)[name];
5 | }
6 |
7 | export default Scene;
8 |
--------------------------------------------------------------------------------
/packages/scenejs/src/presets.ts:
--------------------------------------------------------------------------------
1 | import { IObject } from "@daybrush/utils";
2 | import Scene from "./Scene";
3 | import SceneItem from "./SceneItem";
4 | import { SceneOptions, SceneItemOptions } from "./types";
5 |
6 | export function animate(properties?: IObject, options?: Partial) {
7 | return new Scene(properties, options).play();
8 | }
9 | export function animateItem(properties?: IObject, options?: Partial) {
10 | return new SceneItem(properties, options).play();
11 | }
12 |
--------------------------------------------------------------------------------
/packages/scenejs/src/reactive/Frame.ts:
--------------------------------------------------------------------------------
1 | import { ReactiveAdapter, ReactiveObject, computed, reactive, observe, Observer, isObserver, partialReactive } from "@cfcs/core";
2 | import { isFunction } from "@daybrush/utils";
3 | import Frame from "../Frame";
4 | import { isFrame } from "../utils";
5 | import { ANIMATOR_METHODS, getMethodNames, ReactiveMethods } from "./reactive";
6 |
7 | export const FRAME_METHODS = [
8 | ...ANIMATOR_METHODS,
9 | ...getMethodNames(Frame),
10 | ];
11 |
12 | /**
13 | * @typedef
14 | * @memberof Reactive
15 | */
16 | export type FrameReactiveData
17 | = Observer | Frame | string | Record
18 | | (() => (Observer | Frame | string | Record));
19 |
20 | export type FrameReactiveMethods = ReactiveMethods ;
21 |
22 | /**
23 | * @typedef
24 | * @memberof Reactive
25 | */
26 | export interface FrameReactiveState {
27 | /**
28 | * Returns the frame's cssText.
29 | */
30 | cssText: string;
31 | /**
32 | * Returns the frame's css object (kebab-case).
33 | */
34 | cssObject: Record;
35 | /**
36 | * Returns an object in camel case type of frame. It can be used in React.
37 | */
38 | camelCasedCSSObject: Record;
39 | }
40 |
41 | export type FrameReactiveInstance = ReactiveObject & FrameReactiveMethods & {
42 | getFrameObserver(): Observer ;
43 | onUpdate(): void;
44 | };
45 |
46 | export const FRAME_REACTIVE: ReactiveAdapter<
47 | FrameReactiveInstance,
48 | FrameReactiveState,
49 | keyof FrameReactiveMethods,
50 | FrameReactiveData,
51 | {}
52 | > = {
53 | methods: FRAME_METHODS as Array,
54 | created(data: FrameReactiveData) {
55 | const nextObject = isFunction(data) ? data() : data;
56 | const updateCount = observe(0);
57 | let frame: Observer ;
58 |
59 | if (isObserver(nextObject)) {
60 | frame = nextObject;
61 | } else {
62 | frame = observe(isFrame(nextObject) ? nextObject : new Frame(nextObject));
63 | }
64 |
65 | const cssText = computed(() => {
66 | frame.current;
67 | updateCount.current;
68 |
69 | return frame.current.toCSSText();
70 | });
71 | const cssObject = computed(() => {
72 | frame.current;
73 | cssText.current;
74 |
75 | return frame.current.toCSSObject();
76 | });
77 | const camelCasedCSSObject = computed(() => {
78 | frame.current;
79 | cssText.current;
80 |
81 | return frame.current.toCSSObject(true);
82 | });
83 |
84 | const onUpdate = () => {
85 | ++updateCount.current;
86 | };
87 |
88 | frame.subscribe((currentFrame, prevFrame) => {
89 | prevFrame.off("update", onUpdate);
90 | currentFrame.on("update", onUpdate);
91 | });
92 | const nextReactiveObject = partialReactive({
93 | cssText,
94 | cssObject,
95 | camelCasedCSSObject,
96 | onUpdate,
97 | ...FRAME_METHODS.reduce((obj, cur) => {
98 | obj[cur] = (...args) => {
99 | const currentFrame = frame.current;
100 |
101 | return currentFrame?.[cur].call(currentFrame, ...args);
102 | };
103 | return obj;
104 | }, {}),
105 | }) as FrameReactiveInstance;
106 |
107 | return nextReactiveObject;
108 | },
109 | destroy(inst) {
110 | inst.off("update", inst.onUpdate);
111 | },
112 | };
113 |
--------------------------------------------------------------------------------
/packages/scenejs/src/reactive/NowFrame.ts:
--------------------------------------------------------------------------------
1 | import { observe, ReactiveAdapter } from "@cfcs/core";
2 | import { isFunction } from "@daybrush/utils";
3 | import Frame from "../Frame";
4 | import SceneItem from "../SceneItem";
5 | import { FrameReactiveInstance, FrameReactiveMethods, FrameReactiveState, FRAME_REACTIVE } from "./Frame";
6 |
7 | export type NowFrameData = SceneItem | (() => SceneItem);
8 | export const NOW_FRAME_REACTIVE = {
9 | ...FRAME_REACTIVE,
10 | created(data: NowFrameData) {
11 | const nextObject = isFunction(data) ? data() : data;
12 | const frame = observe(new Frame());
13 |
14 | nextObject.on("animate", e => {
15 | frame.current = e.frame;
16 | });
17 |
18 | return FRAME_REACTIVE.created(frame);
19 | },
20 | } as ReactiveAdapter<
21 | FrameReactiveInstance,
22 | FrameReactiveState,
23 | keyof FrameReactiveMethods,
24 | SceneItem,
25 | {}
26 | >;
27 |
--------------------------------------------------------------------------------
/packages/scenejs/src/reactive/Scene.ts:
--------------------------------------------------------------------------------
1 | import {
2 | ReactiveObject, ReactiveAdapter,
3 | getObservers, computed,
4 | partialReactive,
5 | } from "@cfcs/core";
6 | import { isFunction } from "@daybrush/utils";
7 | import Scene from "../Scene";
8 | import SceneItem from "../SceneItem";
9 | import { SceneOptions, SceneEvents, AnimatorState } from "../types";
10 | import { isScene } from "../utils";
11 | import { ANIMATOR_METHODS, getMethodNames, AnimatorReactiveState, ReactiveMethods } from "./reactive";
12 |
13 | export const SCENE_METHODS = [
14 | ...ANIMATOR_METHODS,
15 | ...getMethodNames(Scene),
16 | ];
17 |
18 | /**
19 | * @typedef
20 | * @memberof Reactive
21 | */
22 | export interface SceneReactiveOptions {
23 | options?: Partial;
24 | [key: string | number]: any;
25 | }
26 |
27 | /**
28 | * @typedef
29 | * @memberof Reactive
30 | */
31 | export type SceneReactiveProps = SceneReactiveOptions | Scene | (() => SceneReactiveOptions | Scene);
32 |
33 | /**
34 | * @typedef
35 | * @memberof Reactive
36 | */
37 | export interface SceneReactiveData {
38 | props?: SceneReactiveProps;
39 | options?: Partial;
40 | }
41 |
42 | export type SceneReactiveMethods = ReactiveMethods;
43 | export type SceneReactiveInstance = ReactiveObject & SceneReactiveMethods & {
44 | getInstance(): Scene;
45 | };
46 |
47 | export const SCENE_REACTIVE: ReactiveAdapter<
48 | SceneReactiveInstance,
49 | AnimatorReactiveState,
50 | keyof SceneReactiveMethods,
51 | SceneReactiveData,
52 | SceneEvents
53 | > = {
54 | methods: SCENE_METHODS as Array,
55 | created(data: SceneReactiveData) {
56 | const dataProps = data.props;
57 | const dataObject = isFunction(dataProps) ? dataProps() : dataProps;
58 | const scene = isScene(dataObject)
59 | ? dataObject
60 | : new Scene(dataObject, {
61 | noRegisterElement: false,
62 | ...data.options,
63 | });
64 | const obj = scene.state as any as ReactiveObject;
65 | const observers = getObservers(obj);
66 |
67 | const totalDuration = computed(() => {
68 | return scene.getTotalDuration();
69 | });
70 | const nextObj = {
71 | totalDuration,
72 | ...observers,
73 | ...SCENE_METHODS.reduce((methodObject, cur) => {
74 | methodObject[cur] = (...args) => {
75 | return scene[cur].call(scene, ...args);
76 | };
77 | return methodObject;
78 | }, {}),
79 | getInstance() {
80 | return scene;
81 | },
82 | };
83 |
84 | const nextReactiveObject = partialReactive(nextObj) as SceneReactiveInstance;
85 |
86 | return nextReactiveObject;
87 | },
88 | mounted(data, inst) {
89 | const scene = inst.getInstance();
90 | const state = scene.state;
91 | const selector = state.selector;
92 |
93 | if (selector && !(state as any).__REACTIVE_MOUNTED__) {
94 | inst.setSelector(selector);
95 | (state as any).__REACTIVE_MOUNTED__ = true;
96 | inst.forEach(function mountFlag(child: Scene | SceneItem) {
97 | const childState = child.state;
98 |
99 | if (childState.selector) {
100 | (childState as any).__REACTIVE_MOUNTED__ = true;
101 | }
102 | if (isScene(child)) {
103 | child.forEach(mountFlag);
104 | }
105 | });
106 | }
107 | },
108 | on(inst, eventName, callback) {
109 | inst.on(eventName, callback);
110 | },
111 | off(inst, eventName, callback) {
112 | inst.off(eventName, callback);
113 | },
114 | destroy(inst) {
115 | const scene = inst.getInstance();
116 | const state = scene.state;
117 |
118 | (state as any).__REACTIVE_MOUNTED__ = false;
119 |
120 | inst.forEach(function unmountFlag(child: Scene | SceneItem) {
121 | (child.state as any).__REACTIVE_MOUNTED__ = false;
122 |
123 | if (isScene(child)) {
124 | child.forEach(unmountFlag);
125 | }
126 | });
127 | },
128 | };
129 |
--------------------------------------------------------------------------------
/packages/scenejs/src/reactive/SceneItem.ts:
--------------------------------------------------------------------------------
1 | import { ReactiveAdapter, ReactiveObject, getObservers, computed, reactive, partialReactive } from "@cfcs/core";
2 | import { isFunction } from "@daybrush/utils";
3 | import Scene from "../Scene";
4 | import SceneItem from "../SceneItem";
5 | import { SceneItemEvents, AnimatorState, SceneItemOptions } from "../types";
6 | import { isSceneItem } from "../utils";
7 | import { ANIMATOR_METHODS, getMethodNames, AnimatorReactiveState, ReactiveMethods } from "./reactive";
8 |
9 | export const SCENE_ITEM_METHODS = [
10 | ...ANIMATOR_METHODS,
11 | ...getMethodNames(Scene),
12 | ];
13 |
14 | /**
15 | * @typedef
16 | * @memberof Reactive
17 | */
18 | export interface SceneItemReactiveOptions {
19 | options?: Partial;
20 | [key: string | number]: any;
21 | }
22 |
23 | /**
24 | * @typedef
25 | * @memberof Reactive
26 | */
27 | export type SceneItemReactiveProps = SceneItemReactiveOptions
28 | | SceneItem
29 | | (() => SceneItemReactiveOptions | SceneItem);
30 |
31 | /**
32 | * @typedef
33 | * @memberof Reactive
34 | */
35 | export interface SceneItemReactiveData {
36 | props?: SceneItemReactiveProps;
37 | options?: Partial;
38 | }
39 |
40 | export type SceneItemReactiveMethods = ReactiveMethods;
41 | export type SceneItemReactiveInstance = ReactiveObject & SceneItemReactiveMethods & {
42 | getInstance(): SceneItem;
43 | };
44 |
45 | export const SCENE_ITEM_REACTIVE: ReactiveAdapter<
46 | SceneItemReactiveInstance,
47 | AnimatorReactiveState,
48 | keyof SceneItemReactiveMethods,
49 | SceneItemReactiveData,
50 | SceneItemEvents
51 | > = {
52 | methods: SCENE_ITEM_METHODS as Array,
53 | created(data: SceneItemReactiveData) {
54 | const dataProps = data.props;
55 | const dataObject = isFunction(dataProps) ? dataProps() : dataProps;
56 | const sceneItem = isSceneItem(dataObject)
57 | ? dataObject
58 | : new SceneItem(dataObject, {
59 | noRegisterElement: false,
60 | ...data.options,
61 | });
62 | const obj = sceneItem.state as any as ReactiveObject;
63 | const observers = getObservers(obj);
64 | const totalDuration = computed(() => {
65 | return sceneItem.getTotalDuration();
66 | });
67 | const nextObj = {
68 | totalDuration,
69 | ...observers,
70 | ...SCENE_ITEM_METHODS.reduce((methodObject, cur) => {
71 | methodObject[cur] = (...args) => {
72 | return sceneItem[cur].call(sceneItem, ...args);
73 | };
74 | return methodObject;
75 | }, {}),
76 | getInstance() {
77 | return sceneItem;
78 | },
79 | };
80 |
81 | const nextReactiveObject = partialReactive(nextObj) as SceneItemReactiveInstance;
82 |
83 | return nextReactiveObject;
84 | },
85 | mounted(data, inst) {
86 | const item = inst.getInstance();
87 | const state = item.state;
88 | const selector = state.selector;
89 |
90 | if (selector && !(state as any).__REACTIVE_MOUNTED__) {
91 | inst.setSelector(selector);
92 | (state as any).__REACTIVE_MOUNTED__ = true;
93 | }
94 | },
95 | on(inst, eventName, callback) {
96 | inst.on(eventName, callback);
97 | },
98 | off(inst, eventName, callback) {
99 | inst.off(eventName, callback);
100 | },
101 | destroy(inst) {
102 | const scene = inst.getInstance();
103 | const state = scene.state;
104 |
105 | (state as any).__REACTIVE_MOUNTED__ = false;
106 | inst.finish();
107 | },
108 | };
109 |
--------------------------------------------------------------------------------
/packages/scenejs/src/reactive/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @namespace Reactive
3 | */
4 |
5 | export * from "./reactive";
6 | export * from "./Scene";
7 | export * from "./SceneItem";
8 | export * from "./Frame";
9 | export * from "./NowFrame";
10 |
--------------------------------------------------------------------------------
/packages/scenejs/src/reactive/reactive.ts:
--------------------------------------------------------------------------------
1 |
2 | import { ExtractNever } from "@cfcs/core";
3 | import { getKeys, isFunction } from "@daybrush/utils";
4 | import EventEmitter from "@scena/event-emitter";
5 | import Animator from "../Animator";
6 | import { AnimatorState } from "../types";
7 |
8 | export function getMethodNames(classConstructor: new (...args: any[]) => any) {
9 | const prototype = classConstructor.prototype;
10 |
11 | return getKeys(prototype).filter(name => {
12 | const descriptor = Object.getOwnPropertyDescriptor(prototype, name);
13 |
14 | if (name === "constructor") {
15 | return false;
16 | }
17 | return !descriptor.get && !descriptor.set && isFunction(descriptor.value || prototype[name]);
18 | });
19 | }
20 |
21 | const EMITTER_METHODS = getMethodNames(EventEmitter);
22 |
23 | export const ANIMATOR_METHODS = [
24 | ...EMITTER_METHODS,
25 | ...getMethodNames(Animator),
26 | ];
27 |
28 | export type ReactiveMethods = ExtractNever<{
29 | [key in (keyof Instance) & string]: Instance[key] extends (...args: any) => any ? Instance[key] : never;
30 | }>;
31 |
32 | /**
33 | * @typedef
34 | * @memberof Reactive
35 | */
36 | export interface AnimatorReactiveState extends AnimatorState {
37 | /**
38 | * Total time the animation played
39 | */
40 | totalDuration: number;
41 | }
42 |
--------------------------------------------------------------------------------
/packages/scenejs/src/utils/dot.ts:
--------------------------------------------------------------------------------
1 |
2 | import PropertyObject from "../PropertyObject";
3 | import { getType } from "../utils";
4 | import { toPropertyObject } from "./property";
5 | import { splitUnit, PROPERTY, FUNCTION, ARRAY, dot as dotNumber } from "@daybrush/utils";
6 | import { EasingType } from "../types";
7 |
8 | function dotArray(a1: any[], a2: any, b1: number, b2: number): any {
9 | const length = a2.length;
10 |
11 | return a1.map((v1, i) => {
12 | if (i >= length) {
13 | return v1;
14 | } else {
15 | return dot(v1, a2[i], b1, b2);
16 | }
17 | });
18 | }
19 |
20 | function dotColor(color1: PropertyObject, color2: PropertyObject, b1: number, b2: number) {
21 | // convert array to PropertyObject(type=color)
22 | const value1 = color1.value;
23 | const value2 = color2.value;
24 | // If the model name is not same, the inner product is impossible.
25 | const model1 = color1.model;
26 | const model2 = color2.model;
27 |
28 | if (model1 !== model2) {
29 | // It is recognized as a string.
30 | return dot(color1.toValue(), color2.toValue(), b1, b2);
31 | }
32 | if (value1.length === 3) {
33 | value1[3] = 1;
34 | }
35 | if (value2.length === 3) {
36 | value2[3] = 1;
37 | }
38 | const v = dotArray(value1, value2, b1, b2);
39 | const colorModel = model1;
40 |
41 | for (let i = 0; i < 3; ++i) {
42 | v[i] = parseInt(v[i], 10);
43 | }
44 | const object = new PropertyObject(v, {
45 | type: "color",
46 | model: colorModel,
47 | prefix: `${colorModel}(`,
48 | suffix: ")",
49 | });
50 |
51 | return object;
52 | }
53 |
54 | function dotObject(a1: PropertyObject, a2: PropertyObject, b1: number, b2: number) {
55 | const a1Type = a1.type;
56 |
57 | if (a1Type === "color") {
58 | return dotColor(a1, a2, b1, b2);
59 | }
60 | const value1 = a1.value;
61 | const value2 = a2.value;
62 | const arr = dotArray(value1, value2, b1, b2);
63 |
64 | return new PropertyObject(arr, {
65 | type: a1Type,
66 | separator: a1.separator || a2.separator,
67 | prefix: a1.prefix || a2.prefix,
68 | suffix: a1.suffix || a2.suffix,
69 | model: a1.model || a2.model,
70 | });
71 | }
72 | /**
73 | * The dot product of a1 and a2 for the b1 and b2.
74 | * @memberof Dot
75 | * @function dot
76 | * @param {String|Number|PropertyObject} a1 value1
77 | * @param {String|Number|PropertyObject} a2 value2
78 | * @param {Number} b1 b1 ratio
79 | * @param {Number} b2 b2 ratio
80 | * @return {String} Not Array, Not Separator, Only Number & Unit
81 | * @return {PropertyObject} Array with Separator.
82 | * @example
83 | dot(1, 3, 0.3, 0.7);
84 | // => 1.6
85 | */
86 | export function dot(a1: any, a2: any, b1: number, b2: number): any {
87 | if (b2 === 0) {
88 | return a2;
89 | } else if (b1 === 0 || b1 + b2 === 0) {
90 | // prevent division by zero.
91 | return a1;
92 | }
93 | // dot Object
94 |
95 | const type1 = getType(a1);
96 | const type2 = getType(a2);
97 | const isFunction1 = type1 === FUNCTION;
98 | const isFunction2 = type2 === FUNCTION;
99 |
100 | if (isFunction1 || isFunction2) {
101 | return () => {
102 | return dot(isFunction1 ? toPropertyObject(a1()) : a1, isFunction2 ? toPropertyObject(a2()) : a2, b1, b2);
103 | };
104 | } else if (type1 === type2) {
105 | if (type1 === PROPERTY) {
106 | return dotObject(a1, a2, b1, b2);
107 | } else if (type1 === ARRAY) {
108 | return dotArray(a1, a2, b1, b2);
109 | } else if (type1 !== "value") {
110 | return a1;
111 | }
112 | } else {
113 | return a1;
114 | }
115 | const v1 = splitUnit(`${a1}`);
116 | const v2 = splitUnit(`${a2}`);
117 | let v;
118 |
119 | // 숫자가 아닐경우 첫번째 값을 반환 b2가 0일경우 두번째 값을 반환
120 | if (isNaN(v1.value) || isNaN(v2.value)) {
121 | return a1;
122 | } else {
123 | v = dotNumber(v1.value, v2.value, b1, b2);
124 | }
125 | const prefix = v1.prefix || v2.prefix;
126 | const unit = v1.unit || v2.unit;
127 |
128 | if (!prefix && !unit) {
129 | return v;
130 | }
131 | return prefix + v + unit;
132 | }
133 |
134 | export function dotValue(
135 | time: number,
136 | prevTime: number,
137 | nextTime: number,
138 | prevValue: any,
139 | nextValue: any,
140 | easing?: EasingType) {
141 | if (time === prevTime) {
142 | return prevValue;
143 | } else if (time === nextTime) {
144 | return nextValue;
145 | } else if (!easing) {
146 | return dot(prevValue, nextValue, time - prevTime, nextTime - time);
147 | }
148 | const ratio = easing((time - prevTime) / (nextTime - prevTime));
149 | const value = dot(prevValue, nextValue, ratio, 1 - ratio);
150 |
151 | return value;
152 | }
153 |
--------------------------------------------------------------------------------
/packages/scenejs/test/manual/easing.html:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
--------------------------------------------------------------------------------
/packages/scenejs/test/unit/PropertyObject.spec.ts:
--------------------------------------------------------------------------------
1 | import PropertyObject from "../../src/PropertyObject";
2 | /* eslint-disable */
3 |
4 | describe("PropertyObject Test", () => {
5 | describe("test PropertyObject initialize", () => {
6 | it("should check PropertyObject initialize", () => {
7 | const obj = new PropertyObject("1,1,1");
8 |
9 | // When
10 | // Then
11 | expect(obj.get(0)).to.be.equals("1");
12 | expect(obj.get(1)).to.be.equals("1");
13 | expect(obj.get(2)).to.be.equals("1");
14 | expect(obj.toValue()).to.be.equals("1,1,1");
15 | });
16 | it("should check set method", () => {
17 | const obj = new PropertyObject("1,1,1");
18 |
19 | // When
20 | obj.set(1, "2");
21 | obj.set(3, 3);
22 | // Then
23 | expect(obj.get(0)).to.be.equals("1");
24 | expect(obj.get(1)).to.be.equals("2");
25 | expect(obj.get(2)).to.be.equals("1");
26 | expect(obj.get(3)).to.be.equals(3);
27 | expect(obj.toValue()).to.be.equals("1,2,1,3");
28 | });
29 | });
30 | });
31 |
--------------------------------------------------------------------------------
/packages/scenejs/test/unit/TestHelper.ts:
--------------------------------------------------------------------------------
1 | import { Animator, AnimatorEvents } from "../../src";
2 |
3 | export function orderByASC(arr: any[]) {
4 | return arr.map(v => parseFloat(v)).sort((a, b) => a - b);
5 | }
6 | export function group(arr: any[]) {
7 | const result: any[] = [];
8 |
9 | arr.forEach(value => {
10 | (result.indexOf(value) === -1) && result.push(value);
11 | });
12 | return result;
13 | }
14 |
15 | export function waitFor(time: number) {
16 | return new Promise(resolve => {
17 | setTimeout(() => {
18 | resolve();
19 | }, time);
20 | });
21 | }
22 | export function waitEvent(et: T, name: keyof AnimatorEvents | (T extends Animator ? keyof Events : never)) {
23 | return new Promise(resolve => {
24 | et.once(name, e => {
25 | resolve(e);
26 | });
27 | });
28 | }
29 |
--------------------------------------------------------------------------------
/packages/scenejs/test/unit/easing.spec.ts:
--------------------------------------------------------------------------------
1 | import { bezier, STEP_START, STEP_END, steps } from "../../src/easing";
2 |
3 | describe("cubic bezier Test", () => {
4 | describe("test easing ", () => {
5 | it("should check linear", () => {
6 | const curve = bezier(0, 0, 1, 1);
7 |
8 | for (let i = 0; i <= 1; i += 0.1) {
9 | expect(curve(i)).to.be.closeTo(i, 0.01);
10 | }
11 | });
12 | it("should check steps", () => {
13 | const steps4 = steps(4, "start");
14 | const steps4end = steps(4, "end");
15 |
16 | expect(STEP_START(0)).to.be.equals(1);
17 | expect(STEP_START(0.5)).to.be.equals(1);
18 | expect(STEP_START(1)).to.be.equals(1);
19 | expect(STEP_END(0)).to.be.equals(0);
20 | expect(STEP_END(0.5)).to.be.equals(0);
21 | expect(STEP_END(1)).to.be.equals(1);
22 |
23 | expect(steps4(0)).to.be.equals(0.25);
24 | expect(steps4(0.1)).to.be.equals(0.25);
25 | expect(steps4(0.25)).to.be.equals(0.5);
26 | expect(steps4(0.6)).to.be.equals(0.75);
27 | expect(steps4(0.9)).to.be.equals(1);
28 | expect(steps4(1)).to.be.equals(1);
29 |
30 | expect(steps4end(0)).to.be.equals(0);
31 | expect(steps4end(0.1)).to.be.equals(0);
32 | expect(steps4end(0.25)).to.be.equals(0.25);
33 | expect(steps4end(0.6)).to.be.equals(0.5);
34 | expect(steps4end(0.9)).to.be.equals(0.75);
35 | expect(steps4end(1)).to.be.equals(1);
36 | });
37 | });
38 | });
39 |
--------------------------------------------------------------------------------
/packages/scenejs/test/unit/injections/ClassListInjection.ts:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | export default function removeProperty(element, property) {
3 | Object.defineProperty(element, property, {
4 | get: () => {
5 | return undefined;
6 | },
7 | });
8 | }
9 |
--------------------------------------------------------------------------------
/packages/scenejs/test/unit/presets.spec.ts:
--------------------------------------------------------------------------------
1 | import Scene, { animate, animateItem, SceneItem, EASE_IN } from "../../src";
2 |
3 | describe("presets Test", () => {
4 | it("test animate method", () => {
5 | // Given, When
6 | const scene = animate({
7 | ".item": {
8 | 0: {
9 | a: 0,
10 | },
11 | 1: {
12 | a: 1,
13 | },
14 | },
15 | });
16 | const playState = scene.getPlayState();
17 |
18 | scene.pause();
19 | const frame = scene.getItem(".item").getNowFrame(0.5);
20 | const playState2 = scene.getPlayState();
21 | // Then
22 | expect(playState).to.be.equals("running");
23 | expect(playState2).to.be.equals("paused");
24 | expect(frame.get("a")).to.be.equals(0.5);
25 | });
26 | it("test animate method with easing", () => {
27 | // Given, When
28 | const scene = animate({
29 | ".item": {
30 | 0: {
31 | a: 0,
32 | },
33 | 1: {
34 | a: 1,
35 | },
36 | },
37 | }, {
38 | easing: "ease-in",
39 | });
40 | const playState = scene.getPlayState();
41 |
42 | scene.pause();
43 | const frame = scene.getItem(".item").getNowFrame(0.5, EASE_IN);
44 | const playState2 = scene.getPlayState();
45 | // Then
46 | expect(playState).to.be.equals("running");
47 | expect(playState2).to.be.equals("paused");
48 | expect(scene.getEasingName()).to.be.equals("cubic-bezier(0.42,0,1,1)");
49 | expect(frame.get("a")).to.be.not.equals(0.5);
50 | });
51 | it("test animateItem method", () => {
52 | // Given, When
53 | const item = animateItem({
54 | 0: {
55 | a: 0,
56 | },
57 | 1: {
58 | a: 1,
59 | },
60 | });
61 | const playState = item.getPlayState();
62 |
63 | item.pause();
64 | const frame = item.getNowFrame(0.5);
65 | const playState2 = item.getPlayState();
66 | // Then
67 | expect(playState).to.be.equals("running");
68 | expect(playState2).to.be.equals("paused");
69 | expect(frame.get("a")).to.be.equals(0.5);
70 | });
71 | it("test animateItem method with easing", () => {
72 | // Given, When
73 | const item = animateItem({
74 | 0: {
75 | a: 0,
76 | },
77 | 1: {
78 | a: 1,
79 | },
80 | }, {
81 | easing: "ease-in",
82 | });
83 | const playState = item.getPlayState();
84 |
85 | item.pause();
86 | const frame = item.getNowFrame(0.5);
87 | const playState2 = item.getPlayState();
88 | // Then
89 | expect(playState).to.be.equals("running");
90 | expect(playState2).to.be.equals("paused");
91 | expect(frame.get("a")).to.be.not.equals(0.5);
92 | });
93 | });
94 |
--------------------------------------------------------------------------------
/packages/scenejs/test/unit/utils.spec.ts:
--------------------------------------------------------------------------------
1 | import { splitUnit } from "@daybrush/utils";
2 | import Frame from "../../src/Frame";
3 | import { flatSceneObject, isFrame } from "../../src/utils";
4 |
5 | describe("utils Test", () => {
6 | it("should check 'splitUnit' method", () => {
7 | expect(splitUnit("1234")).to.be.deep.equals({ prefix: "", value: 1234, unit: "" });
8 | expect(splitUnit("d1234")).to.be.deep.equals({ prefix: "d", value: 1234, unit: "" });
9 | expect(splitUnit("d1234d")).to.be.deep.equals({ prefix: "d", value: 1234, unit: "d" });
10 | expect(splitUnit("ddddd")).to.be.deep.equals({ prefix: "", value: NaN, unit: "" });
11 | });
12 | it("test flatSceneObject", () => {
13 | // Given
14 | const frames = {
15 | a: new Frame(),
16 | b: new Frame(),
17 | c: {
18 | c1: new Frame(),
19 | c2: {
20 | c21: new Frame(),
21 | c22: new Frame(),
22 | },
23 | },
24 | };
25 |
26 | // When
27 | const obj = flatSceneObject(frames, "/");
28 | const objKeys = Object.keys(obj);
29 |
30 | // Then
31 | expect(objKeys).to.be.deep.equals(["a", "b", "c/c1", "c/c2/c21", "c/c2/c22"]);
32 | objKeys.forEach(key => {
33 | expect(isFrame(obj[key])).to.be.true;
34 | });
35 | });
36 | });
37 |
--------------------------------------------------------------------------------
/packages/scenejs/test/unit/utils/color.spec.ts:
--------------------------------------------------------------------------------
1 | import { toFullHex, cutHex, hexToRGBA, hslToRGBA } from "@daybrush/utils";
2 | import { rgbaToHexa } from "../../../src/utils";
3 |
4 | describe("color Test", () => {
5 | describe("test color ", () => {
6 | it("should check 'cutHex'", () => {
7 | const hex1 = cutHex("#abc");
8 | const hex2 = cutHex("#aabbcc");
9 | const hex3 = cutHex("#aabbccdd");
10 | const hex4 = cutHex("abcdef");
11 |
12 | // Then
13 | expect(hex1).to.be.equals("abc");
14 | expect(hex2).to.be.equals("aabbcc");
15 | expect(hex3).to.be.equals("aabbccdd");
16 | expect(hex4).to.be.equals("abcdef");
17 | });
18 | it("should check 'toFullHex'", () => {
19 | const hex = toFullHex("#abc");
20 |
21 | // Then
22 | expect(hex).to.be.equals("#aabbcc");
23 | });
24 | it("should check 'hexToRGBA'", () => {
25 | const rgb1 = hexToRGBA("#000000");
26 | const rgb2 = hexToRGBA("#ffffff");
27 | const rgb3 = hexToRGBA("#00000000");
28 | const rgb4 = hexToRGBA("#00000005");
29 |
30 | expect(rgb1).to.be.deep.equals([0, 0, 0, 1]);
31 | expect(rgb2).to.be.deep.equals([255, 255, 255, 1]);
32 | expect(rgb3).to.be.deep.equals([0, 0, 0, 0]);
33 | expect(rgb4).to.be.deep.equals([0, 0, 0, 5 / 255]);
34 | });
35 | it("should check 'hslToRGBA'", () => {
36 | // Given, When
37 | const rgb1 = hslToRGBA([0, 0.4, 0.5]);
38 | const rgb2 = hslToRGBA([80, 0.4, 0.5]);
39 | const rgb3 = hslToRGBA([150, 0.4, 0.5]);
40 | const rgb4 = hslToRGBA([215, 0.4, 0.5]);
41 | const rgb5 = hslToRGBA([260, 0.4, 0.5]);
42 | const rgb6 = hslToRGBA([320, 0.4, 0.5]);
43 | const rgb7 = hslToRGBA([320, 0.4, 0.5, 0.4]);
44 | const rgb8 = hslToRGBA([-40, 0.4, 0.5]);
45 |
46 | // Then
47 | expect(rgb1).to.be.deep.equals([179, 77, 77, 1]);
48 | expect(rgb2).to.be.deep.equals([145, 179, 77, 1]);
49 | expect(rgb3).to.be.deep.equals([77, 179, 128, 1]);
50 | expect(rgb4).to.be.deep.equals([77, 119, 179, 1]);
51 | expect(rgb5).to.be.deep.equals([110, 77, 179, 1]);
52 | expect(rgb6).to.be.deep.equals([179, 77, 145, 1]);
53 | expect(rgb7).to.be.deep.equals([179, 77, 145, 0.4]);
54 | expect(rgb8).to.be.deep.equals([179, 77, 145, 1]);
55 | });
56 | it("should check 'rgbaToHexa'", () => {
57 | // Given, When
58 | const rgba1 = rgbaToHexa(`rgba(179, 77, 77, 1)`);
59 | const rgba2 = rgbaToHexa(`rgba(145, 179, 77, 1)`);
60 | const rgba3 = rgbaToHexa(`rgba(77, 179, 128, 1)`);
61 | const rgba4 = rgbaToHexa(`rgba(77, 119, 179, 1)`);
62 | const rgba5 = rgbaToHexa(`rgba(110, 77, 179, 1)`);
63 | const rgba6 = rgbaToHexa(`rgba(179, 77, 145, 1)`);
64 | const rgba7 = rgbaToHexa(`rgba(179, 77, 145, 0.4)`);
65 | const rgba8 = rgbaToHexa(`rgba(179, 77, 145, 1)`);
66 | const rgba9 = rgbaToHexa(`transparent`);
67 |
68 | // Then
69 | expect(rgba1).to.be.equals("#b34d4dff");
70 | expect(rgba2).to.be.equals("#91b34dff");
71 | expect(rgba3).to.be.equals("#4db380ff");
72 | expect(rgba4).to.be.equals("#4d77b3ff");
73 | expect(rgba5).to.be.equals("#6e4db3ff");
74 | expect(rgba6).to.be.equals("#b34d91ff");
75 | expect(rgba7).to.be.equals("#b34d9166");
76 | expect(rgba8).to.be.equals("#b34d91ff");
77 | expect(rgba9).to.be.equals("");
78 | });
79 | });
80 | });
81 |
--------------------------------------------------------------------------------
/packages/scenejs/test/unit/utils/dot.spec.ts:
--------------------------------------------------------------------------------
1 | import { dot } from "../../../src/utils/dot";
2 | import PropertyObject from "../../../src/PropertyObject";
3 | import { stringToColorObject } from "../../../src/utils/property";
4 | /* eslint-disable */
5 |
6 | describe("utils/dot Test", () => {
7 | describe("test 'dot' methods", () => {
8 | it("should check 'dot' instead of 'dotArray' method", () => {
9 | expect(dot([1, 2, 3], 2, 1, 1)).to.be.deep.equal([1, 2, 3]);
10 | expect(dot([1, 2, 3], "a", 1, 2)).to.be.deep.equal([1, 2, 3]);
11 | expect(dot([1, 2, 3], [2, 3, 4], 1, 1)).to.be.deep.equal([1.5, 2.5, 3.5]);
12 | expect(dot([1, 2, 3, 4], [2, 3, 4], 0, 1)).to.be.deep.equal([1, 2, 3, 4]);
13 | expect(dot([1, 2, 3, 4], [2, 3, 4], 1, 0)).to.be.deep.equal([2, 3, 4]);
14 | expect(dot([1, 2, 3, 4], [2, 3, 4], 1, 1)).to.be.deep.equal([1.5, 2.5, 3.5, 4]);
15 | });
16 | it("should check 'dot' instead of 'dotColor' method(rgb vs rgb)", () => {
17 | const color1 = stringToColorObject("rgb(0, 0, 0)");
18 | const color2 = stringToColorObject("rgb(100, 200, 220)");
19 | const color3 = stringToColorObject("rgba(0, 0, 0, 0.5)");
20 | const color4 = stringToColorObject("rgba(100, 200, 220, 0.2)");
21 | const color5 = new PropertyObject([0, 0, 0], {
22 | model: "rgba",
23 | prefix: "rgba(",
24 | suffix: ")",
25 | });
26 | const color6 = new PropertyObject([50, 40, 20, 1], {
27 | model: "rgba",
28 | prefix: "rgba(",
29 | suffix: ")",
30 | });
31 | expect(dot(color1, color2, 1, 1).toValue()).to.be.equal("rgba(50,100,110,1)");
32 | expect(dot(color1, color3, 1, 1).toValue()).to.be.equal("rgba(0,0,0,0.75)");
33 | expect(dot(color2, color3, 1, 1).toValue()).to.be.equal("rgba(50,100,110,0.75)");
34 | expect(dot(color3, color4, 1, 1).toValue()).to.be.equal("rgba(50,100,110,0.35)");
35 | expect(dot(color3, color5, 1, 1).toValue()).to.be.equal("rgba(0,0,0,0.75)");
36 | expect(dot(color4, color5, 1, 1).toValue()).to.be.equal("rgba(50,100,110,0.6)");
37 | expect(dot(color4, color5, 1, 1).toValue()).to.be.equal("rgba(50,100,110,0.6)");
38 | expect(dot(color5, color6, 1, 1).toValue()).to.be.equal("rgba(25,20,10,1)");
39 | expect(dot(color4, color6, 1, 1).toValue()).to.be.equal("rgba(75,120,120,0.6)");
40 | });
41 | it(`should check 'dot' instead of 'dotObject' method`, () => {
42 | const color5 = new PropertyObject([0, 0, 0], {
43 | type: "color",
44 | model: "rgba",
45 | prefix: "rgba(",
46 | suffix: ")",
47 | });
48 | const color6 = new PropertyObject([50, 40, 20, 1], {
49 | type: "color",
50 | model: "rgba",
51 | prefix: "rgba(",
52 | suffix: ")",
53 | });
54 | const object = new PropertyObject([10, 10, 10]);
55 | const object2 = new PropertyObject([4, 3, 5, 1]);
56 |
57 | expect(dot(color5, color6, 1, 1).toValue()).to.be.equal("rgba(25,20,10,1)");
58 | expect(dot(object, color6, 1, 1).toValue()).to.be.equal("rgba(30,25,15)");
59 | expect(dot(object, object2, 1, 1).toValue()).to.be.equal("7,6.5,7.5");
60 | });
61 | });
62 | });
63 |
--------------------------------------------------------------------------------
/packages/scenejs/tsconfig.declaration.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig",
3 | "compilerOptions": {
4 | "removeComments": false,
5 | "declaration": true,
6 | "emitDeclarationOnly": true,
7 | "declarationDir": "declaration"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/packages/scenejs/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "outDir": "./outjs/",
4 | "esModuleInterop": false,
5 | "sourceMap": true,
6 | "module": "es2015",
7 | "target": "es5",
8 | "experimentalDecorators": true,
9 | "importHelpers": true,
10 | "skipLibCheck": true,
11 | "moduleResolution": "node",
12 | "lib": [
13 | "es2015",
14 | "dom"
15 | ],
16 | },
17 | "include": [
18 | "./src/**/*.ts"
19 | ]
20 | }
--------------------------------------------------------------------------------
/packages/scenejs/tsconfig.test.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig",
3 | "compilerOptions": {
4 | "module": "commonjs",
5 | "noImplicitAny": false,
6 | "strictNullChecks": false,
7 | "types": [
8 | "karma-chai",
9 | "mocha",
10 | ]
11 | },
12 | "include": [
13 | "./src/**/*.ts",
14 | "./test/unit/**/*.ts"
15 | ],
16 | "exclude": [
17 | "./node_modules/**/*.ts"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/packages/scenejs/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "defaultSeverity": "error",
3 | "extends": [
4 | "tslint:recommended"
5 | ],
6 | "rules": {
7 | "jsdoc-format": false,
8 | "forin": false,
9 | "no-console": false,
10 | "no-any": false,
11 | "interface-name": false,
12 | "indent": [
13 | true,
14 | "spaces",
15 | 4
16 | ],
17 | "ordered-imports": false,
18 | "object-literal-sort-keys": false,
19 | "no-unused-expression": false,
20 | "arrow-parens": [
21 | true,
22 | "ban-single-arg-parens"
23 | ],
24 | "max-line-length": [
25 | true,
26 | {
27 | "limit": 120,
28 | "ignore-pattern": "(\\* @)|//"
29 | }
30 | ],
31 | "trailing-comma": [
32 | true,
33 | {
34 | "multiline": {
35 | "objects": "always",
36 | "arrays": "always",
37 | "functions": "always",
38 | "typeLiterals": "ignore"
39 | },
40 | "esSpecCompliant": true
41 | }
42 | ]
43 | }
44 | }
--------------------------------------------------------------------------------
/packages/svelte-scenejs/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules/
2 | /public/build/
3 |
4 | .DS_Store
5 | .svelte-kit/generated
6 | .svelte-kit/types
7 | .svelte-kit/ambient.d.ts
--------------------------------------------------------------------------------
/packages/svelte-scenejs/.svelte-kit/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": "..",
4 | "paths": {},
5 | "rootDirs": [
6 | "..",
7 | "./types"
8 | ],
9 | "importsNotUsedAsValues": "error",
10 | "isolatedModules": true,
11 | "preserveValueImports": true,
12 | "lib": [
13 | "esnext",
14 | "DOM",
15 | "DOM.Iterable"
16 | ],
17 | "moduleResolution": "node",
18 | "module": "esnext",
19 | "target": "esnext"
20 | },
21 | "include": [
22 | "ambient.d.ts",
23 | "./types/**/$types.d.ts",
24 | "../vite.config.ts",
25 | "../src/**/*.js",
26 | "../src/**/*.ts",
27 | "../src/**/*.svelte",
28 | "../src/**/*.js",
29 | "../src/**/*.ts",
30 | "../src/**/*.svelte",
31 | "../tests/**/*.js",
32 | "../tests/**/*.ts",
33 | "../tests/**/*.svelte"
34 | ],
35 | "exclude": [
36 | "../node_modules/**",
37 | "./[!ambient.d.ts]**"
38 | ]
39 | }
--------------------------------------------------------------------------------
/packages/svelte-scenejs/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to this project will be documented in this file.
4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5 |
6 | ## [1.0.0-beta.12](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/compare/svelte-scenejs@1.0.0-beta.9...svelte-scenejs@1.0.0-beta.12) (2023-06-05)
7 |
8 |
9 | ### :mega: Other
10 |
11 | * publish packages ([97ba4e7](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/97ba4e775018179c16b0e5c0035f5a3773b64722))
12 | * publish packages ([f76d778](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/f76d7782ee508fc12f16d250ca0c925f81d2a0e1))
13 | * publish packages ([2f9e242](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/2f9e242c926cb13672d7f6d9924ea7782fb69815))
14 |
15 |
16 |
17 | ## [1.0.0-beta.9](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/compare/svelte-scenejs@1.0.0-beta.4...svelte-scenejs@1.0.0-beta.9) (2023-05-21)
18 |
19 |
20 | ### :rocket: New Features
21 |
22 | * add modules for frameworks ([d1c173d](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/d1c173d72efba70193fbbcf50d8e9e3edb2629ae))
23 |
24 |
25 | ### :bug: Bug Fix
26 |
27 | * fix frameworks' reactive props ([17f9538](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/17f9538823dafad9e36673fe7cc5bfa9178a147e))
28 | * fix partial reactive props ([06f063a](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/06f063acd979e265bee1e09b1971211b65a6aaec))
29 |
30 |
31 | ### :mega: Other
32 |
33 | * publish packages ([b328ba8](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/b328ba8fbbf552d1d8048c280392be59f12da68b))
34 | * publish packages ([275e338](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/275e338931d19f3a75faf4c7f0935eeb848f5a9e))
35 | * publish packages ([eb28736](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/eb2873676adb0fedf18d1e5a52bfdce08552274a))
36 | * publish packages ([0e37841](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/0e37841738e150d6deb13f501bb715421ab040aa))
37 | * publish packages ([002fc93](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/002fc93c9536659b5db95527c019f1e3ad32a1f8))
38 |
39 |
40 |
41 | ## [1.0.0-beta.4](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/compare/svelte-scenejs@1.0.0-beta.3...svelte-scenejs@1.0.0-beta.4) (2022-12-26)
42 |
43 |
44 | ### :mega: Other
45 |
46 | * publish packages ([843ebf6](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/843ebf6d483549c130db47499d69dd4825118798))
47 |
48 |
49 |
50 | ## [1.0.0-beta.3](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/compare/svelte-scenejs@1.0.0-beta.1...svelte-scenejs@1.0.0-beta.3) (2022-12-21)
51 |
52 |
53 | ### :bug: Bug Fix
54 |
55 | * fix docs ([67546f5](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/67546f5e6e06b5f9f4c626657f42038802f4b2b6))
56 | * update modules ([30191b8](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/30191b8e7c195de355d0c01fa9110d6fe0b3df3b))
57 |
58 |
59 | ### :mega: Other
60 |
61 | * publish packages ([1f4a4f3](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/1f4a4f3719f1789fb91c7e744f4bf8261751944f))
62 | * publish packages ([3b63fde](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/3b63fde8232cdc6454a8d8fe1a42b6317d614036))
63 |
64 |
65 |
66 | ## 1.0.0-beta.1 (2022-12-15)
67 |
68 |
69 | ### :rocket: New Features
70 |
71 | * add svelte-scenejs #80 ([5198c5c](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/5198c5c72eaebe5f1b1bd636eb78a19fb688c0f9))
72 |
73 |
74 | ### :bug: Bug Fix
75 |
76 | * remove useless file ([c28c2da](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/c28c2da241f1a05a0bd098d3f1cd9183c964a930))
77 |
78 |
79 | ### :memo: Documentation
80 |
81 | * fix README ([f818dd9](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/f818dd929b687d91b36005b861934538a16e7286))
82 |
83 |
84 | ### :mega: Other
85 |
86 | * publish packages ([60dbab3](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/60dbab3c8ba568b818a0fc1cd941d9dfe64c7be3))
87 | * publish packages ([de47f51](https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs/commit/de47f5187843c7ec208fea797f67d413f530ab8e))
88 |
--------------------------------------------------------------------------------
/packages/svelte-scenejs/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | Svelte Scene.js
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | 🎬 A Svelte Component that create JavaScript & CSS timeline-based animation with Scene.js.
13 |
14 | About Scene.js / API / Features
15 |
16 |
17 | ## 🚀 Exampless
18 | * [Raindrop Selector Example](https://codesandbox.io/s/svelte-raindrop-selector-example-qtc5bn?file=/App.svelte)
19 | * [Raindrop No Selector Example](https://codesandbox.io/s/svelte-raindrop-no-selector-example-73xkeo)
20 |
21 | ## ⚙️ Installation
22 | ```bash
23 | $ npm install svelte-scenejs
24 | ```
25 |
26 |
27 | ## 🎬 Make Scene
28 | ```svelte
29 |
68 |
72 | ```
73 |
74 |
75 |
76 | ## Development
77 |
78 | ### `npm dev`
79 |
80 | Runs the app in the development mode.
81 | Open [http://localhost:5174](http://localhost:5174) to view it in the browser.
82 |
83 | The page will reload if you make edits.
84 | You will also see any lint errors in the console.
85 |
86 |
87 | ## ⭐️ Show Your Support
88 | Please give a ⭐️ if this project helped you!
89 |
90 |
91 | ## 👏 Contributing
92 |
93 | If you have any questions or requests or want to contribute to `scenejs` or other packages, please write the [issue](https://github.com/daybrush/scenejs/issues) or give me a Pull Request freely.
94 |
95 |
96 | ### Code Contributors
97 |
98 | This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
99 |
100 |
101 |
102 |
103 |
104 |
105 | ## Sponsors
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 | ## 🐞 Bug Report
114 |
115 | If you find a bug, please report to us opening a new [Issue](https://github.com/daybrush/scenejs/issues) on GitHub.
116 |
117 |
118 |
119 | ## 📝 License
120 |
121 | This project is [MIT](https://github.com/daybrush/scenejs/blob/master/LICENSE) licensed.
122 |
123 |
124 | ## License
125 |
126 | ```
127 |
128 | MIT License
129 |
130 | Copyright (c) 2016 Daybrush
131 |
132 | Permission is hereby granted, free of charge, to any person obtaining a copy
133 | of this software and associated documentation files (the "Software"), to deal
134 | in the Software without restriction, including without limitation the rights
135 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
136 | copies of the Software, and to permit persons to whom the Software is
137 | furnished to do so, subject to the following conditions:
138 |
139 | The above copyright notice and this permission notice shall be included in all
140 | copies or substantial portions of the Software.
141 |
142 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
143 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
144 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
145 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
146 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
147 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
148 | SOFTWARE.
149 | ```
--------------------------------------------------------------------------------
/packages/svelte-scenejs/global.d.ts:
--------------------------------------------------------------------------------
1 | declare module "!!raw-loader!*" {
2 | const content: string;
3 | export default content;
4 | }
5 | declare module "*.svelte" {
6 | const content: any;
7 | export default content;
8 | }
9 |
--------------------------------------------------------------------------------
/packages/svelte-scenejs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "svelte-scenejs",
3 | "version": "1.0.0-beta.12",
4 | "type": "module",
5 | "lernaHelperReleaseType": "prerelease",
6 | "lernaHelperPublishTag": "latest",
7 | "description": "A React Component that create JavaScript & CSS timeline-based animation with Scene.js.",
8 | "svelte": "./dist/scene.esm.js",
9 | "main": "./dist/scene.cjs.js",
10 | "module": "./dist/scene.esm.js",
11 | "sideEffects": false,
12 | "types": "declaration/index.d.ts",
13 | "keywords": [
14 | "svelte",
15 | "reactive",
16 | "use",
17 | "scene",
18 | "scene.js",
19 | "scenejs",
20 | "keyframes",
21 | "timeline",
22 | "animate",
23 | "animation",
24 | "css",
25 | "requestAnimationFrame",
26 | "motion"
27 | ],
28 | "license": "MIT",
29 | "repository": {
30 | "type": "git",
31 | "url": "https://github.com/daybrush/scenejs/blob/master/packages/svelte-scenejs"
32 | },
33 | "author": "Daybrush",
34 | "bugs": {
35 | "url": "https://github.com/daybrush/scenejs/issues"
36 | },
37 | "homepage": "https://github.com/daybrush/scenejs",
38 | "files": [
39 | "./*",
40 | "dist/*"
41 | ],
42 | "scripts": {
43 | "dev": "vite dev",
44 | "start": "sirv public --no-clear",
45 | "build": "rollup -c && npm run declaration",
46 | "declaration": "rm -rf declaration && tsc -p tsconfig.declaration.json"
47 | },
48 | "dependencies": {
49 | "@cfcs/svelte": "^0.1.0",
50 | "scenejs": "~1.10.3"
51 | },
52 | "devDependencies": {
53 | "@daybrush/builder": "^0.2.0",
54 | "@sveltejs/adapter-auto": "^1.0.0",
55 | "@sveltejs/kit": "^1.0.0",
56 | "svelte": "^3.54.0",
57 | "svelte-check": "^2.9.2",
58 | "tslib": "^2.4.1",
59 | "typescript": "^4.5.0 <4.6.0",
60 | "vite": "^4.0.0"
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/packages/svelte-scenejs/public/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/packages/svelte-scenejs/public/favicon.png
--------------------------------------------------------------------------------
/packages/svelte-scenejs/public/global.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 | }
6 |
7 | body {
8 | color: #333;
9 | margin: 0;
10 | padding: 8px;
11 | box-sizing: border-box;
12 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
13 | }
14 |
15 | a {
16 | color: rgb(0,100,200);
17 | text-decoration: none;
18 | }
19 |
20 | a:hover {
21 | text-decoration: underline;
22 | }
23 |
24 | a:visited {
25 | color: rgb(0,80,160);
26 | }
27 |
28 | label {
29 | display: block;
30 | }
31 |
32 | input, button, select, textarea {
33 | font-family: inherit;
34 | font-size: inherit;
35 | -webkit-padding: 0.4em 0;
36 | padding: 0.4em;
37 | margin: 0 0 0.5em 0;
38 | box-sizing: border-box;
39 | border: 1px solid #ccc;
40 | border-radius: 2px;
41 | }
42 |
43 | input:disabled {
44 | color: #ccc;
45 | }
46 |
47 | button {
48 | color: #333;
49 | background-color: #f4f4f4;
50 | outline: none;
51 | }
52 |
53 | button:disabled {
54 | color: #999;
55 | }
56 |
57 | button:not(:disabled):active {
58 | background-color: #ddd;
59 | }
60 |
61 | button:focus {
62 | border-color: #666;
63 | }
64 |
--------------------------------------------------------------------------------
/packages/svelte-scenejs/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Svelte app
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/packages/svelte-scenejs/rollup.config.js:
--------------------------------------------------------------------------------
1 | import builder from "@daybrush/builder";
2 |
3 | const defaultOptions = {
4 | tsconfig: "",
5 | commonjs: true,
6 | external: {
7 | svelte: "svelte",
8 | },
9 | };
10 |
11 | export default builder([
12 | {
13 | ...defaultOptions,
14 | input: "./src/svelte-scenejs/index.ts",
15 | output: "dist/scene.cjs.js",
16 | format: "cjs",
17 | exports: "named",
18 | },
19 | {
20 | ...defaultOptions,
21 | input: "./src/svelte-scenejs/index.ts",
22 | output: "dist/scene.esm.js",
23 | format: "es",
24 | exports: "named",
25 | },
26 | ]);
27 |
--------------------------------------------------------------------------------
/packages/svelte-scenejs/src/app.d.ts:
--------------------------------------------------------------------------------
1 | // See https://kit.svelte.dev/docs/types#app
2 | // for information about these interfaces
3 | // and what to do when importing types
4 | declare namespace App {
5 | // interface Error {}
6 | // interface Locals {}
7 | // interface PageData {}
8 | // interface Platform {}
9 | }
10 |
--------------------------------------------------------------------------------
/packages/svelte-scenejs/src/app.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | %sveltekit.head%
8 |
9 |
10 | %sveltekit.body%
11 |
12 |
13 |
--------------------------------------------------------------------------------
/packages/svelte-scenejs/src/routes/+page.svelte:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/packages/svelte-scenejs/src/routes/Motion.svelte:
--------------------------------------------------------------------------------
1 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
101 |
102 |
103 |
104 |
105 |
221 |
--------------------------------------------------------------------------------
/packages/svelte-scenejs/src/svelte-scenejs/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @namespace SvelteScene
3 | */
4 | export * from "./useScene";
5 | export * from "./useSceneItem";
6 | export * from "./useFrame";
7 | export * from "./useNowFrame";
8 | export * from "scenejs";
9 |
--------------------------------------------------------------------------------
/packages/svelte-scenejs/src/svelte-scenejs/useFrame.ts:
--------------------------------------------------------------------------------
1 | import { SvelteReactiveAdapterResult, useReactive } from "@cfcs/svelte";
2 | import { FRAME_REACTIVE, FrameReactiveData } from "scenejs";
3 |
4 |
5 | /**
6 | * You can use reactive state and frame methods.
7 | * To access the state in Svelte you need to add $ prefix.
8 | * @typedef
9 | * @memberof SvelteScene
10 | * @see Frame
11 | * @extends Reactive.FrameReactiveState
12 | */
13 | export interface SvelteFrameResult extends SvelteReactiveAdapterResult { }
14 |
15 | /**
16 | * @memberof SvelteScene
17 | * @param {Reactive.FrameReactiveData} - Can be used as frame, cssText, cssObject, etc.
18 | * @return - You can use Frame methods and cssText, cssObject, ...etc
19 | * @example
20 | * import { useFrame } from "svelte-scenejs";
21 | *
22 | * const { cssText } = useFrame("text-align: center; transform: translate(10px, 10px);");
23 | *
24 | * $cssText;
25 | */
26 | export function useFrame(props: FrameReactiveData): SvelteFrameResult {
27 | return useReactive({
28 | ...FRAME_REACTIVE,
29 | data: () => props,
30 | });
31 | }
32 |
--------------------------------------------------------------------------------
/packages/svelte-scenejs/src/svelte-scenejs/useNowFrame.ts:
--------------------------------------------------------------------------------
1 | import { SvelteReactiveAdapterResult, useReactive } from "@cfcs/svelte";
2 | import { SceneItem, NOW_FRAME_REACTIVE } from "scenejs";
3 |
4 |
5 | /**
6 | * To access the state in Svelte you need to add $ prefix.
7 | * @typedef
8 | * @memberof SvelteScene
9 | * @extends SvelteScene.ReactFrameResult
10 | */
11 | export interface SvelteNowFrameResult extends SvelteReactiveAdapterResult { }
12 |
13 | /**
14 | * @memberof SvelteScene
15 | * @param - item to get the current frame
16 | * @return - You can use Frame methods and cssText, cssObject, ...etc State
17 | * @example
18 | * import { useSceneItem, useNowFrame } from "svelte-scenejs";
19 | *
20 | * const sceneItem = useSceneItem(...);
21 | * const { cssText } = useNowFrame(sceneItem);
22 | *
23 | * $cssText;
24 | */
25 | export function useNowFrame(item: SceneItem): SvelteNowFrameResult {
26 | return useReactive({
27 | ...NOW_FRAME_REACTIVE,
28 | data: () => item,
29 | });
30 | }
31 |
--------------------------------------------------------------------------------
/packages/svelte-scenejs/src/svelte-scenejs/useScene.ts:
--------------------------------------------------------------------------------
1 | import { SvelteReactiveAdapterResult, useReactive } from "@cfcs/svelte";
2 | import { SceneOptions, SceneReactiveProps, SCENE_REACTIVE } from "scenejs";
3 |
4 |
5 | /**
6 | * To access the state in Svelte you need to add $ prefix.
7 | * @typedef
8 | * @memberof SvelteScene
9 | * @extends Reactive.AnimatorReactiveState
10 | */
11 | export interface SvelteSceneResult extends SvelteReactiveAdapterResult { }
12 |
13 |
14 | /**
15 | * @memberof SvelteScene
16 | * @param {Reactive.SceneReactiveProps} - Items and properties that make up the scene
17 | * @param - Scene and Animator options
18 | * @return - You can use Scene methods and Animator State
19 | * @example
20 | * import { useScene, useNowFrame } from "svelte-scenejs";
21 | *
22 | * const scene = useScene({ ... });
23 | * const { cssText } = useNowFrame(scene.getItem("a1"));
24 | *
25 | * $cssText
26 | */
27 | export function useScene(props?: SceneReactiveProps, options?: Partial): SvelteSceneResult {
28 | return useReactive({
29 | ...SCENE_REACTIVE,
30 | data() {
31 | return {
32 | props,
33 | options,
34 | };
35 | },
36 | });
37 | }
38 |
--------------------------------------------------------------------------------
/packages/svelte-scenejs/src/svelte-scenejs/useSceneItem.ts:
--------------------------------------------------------------------------------
1 | import { SvelteReactiveAdapterResult, useReactive } from "@cfcs/svelte";
2 | import { SCENE_ITEM_REACTIVE, SceneItemOptions, SceneItemReactiveProps } from "scenejs";
3 |
4 | /**
5 | * To access the state in Svelte you need to add $ prefix.
6 | * @typedef
7 | * @memberof SvelteScene
8 | * @extends Reactive.AnimatorReactiveState
9 | */
10 | export interface SvelteSceneItemResult extends SvelteReactiveAdapterResult { }
11 |
12 | /**
13 | * @memberof SvelteScene
14 | * @param {Reactive.SceneItemReactiveProps} - Items and properties that make up the scene item
15 | * @param - SceneItem and Animator options
16 | * @return - You can use SceneItem methods and Animator State.
17 | * @example
18 | * import { useSceneItem, useNowFrame } from "svelte-scenejs";
19 | *
20 | * const item = useSceneItem({ ... });
21 | * const { cssText } = useNowFrame(item);
22 | *
23 | * $cssText
24 | */
25 | export function useSceneItem(props?: SceneItemReactiveProps, options?: Partial) {
26 | return useReactive({
27 | ...SCENE_ITEM_REACTIVE,
28 | data: () => ({
29 | props,
30 | options,
31 | }),
32 | });
33 | }
34 |
--------------------------------------------------------------------------------
/packages/svelte-scenejs/svelte.config.js:
--------------------------------------------------------------------------------
1 | import adapter from '@sveltejs/adapter-auto';
2 | import { vitePreprocess } from '@sveltejs/kit/vite';
3 |
4 | /** @type {import('@sveltejs/kit').Config} */
5 | const config = {
6 | // Consult https://kit.svelte.dev/docs/integrations#preprocessors
7 | // for more information about preprocessors
8 | preprocess: vitePreprocess(),
9 |
10 | kit: {
11 | adapter: adapter()
12 | }
13 | };
14 |
15 | export default config;
16 |
--------------------------------------------------------------------------------
/packages/svelte-scenejs/tsconfig.declaration.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig",
3 | "compilerOptions": {
4 | "allowJs": false,
5 | "noEmit": false,
6 | "isolatedModules": false,
7 | "removeComments": false,
8 | "declaration": true,
9 | "emitDeclarationOnly": true,
10 | "declarationDir": "declaration"
11 | },
12 | "include": ["src/svelte-scenejs/**/*.ts"],
13 | "exclude": ["node_modules"],
14 | }
15 |
--------------------------------------------------------------------------------
/packages/svelte-scenejs/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "outDir": "./outjs/",
4 | "lib": [
5 | "dom",
6 | "dom.iterable",
7 | "esnext"
8 | ],
9 | "allowJs": true,
10 | "skipLibCheck": true,
11 | "esModuleInterop": true,
12 | "allowSyntheticDefaultImports": true,
13 | "strict": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "noFallthroughCasesInSwitch": true,
16 | "module": "esnext",
17 | "moduleResolution": "node",
18 | "resolveJsonModule": true,
19 | "isolatedModules": true,
20 | "noEmit": true,
21 | "experimentalDecorators": true
22 | },
23 | "include": [
24 | "./src/**/*.ts"
25 | ],
26 | "exclude": ["node_modules", "__sapper__/*", "public/*"]
27 | }
28 |
--------------------------------------------------------------------------------
/packages/svelte-scenejs/vite.config.js:
--------------------------------------------------------------------------------
1 | import { sveltekit } from '@sveltejs/kit/vite';
2 |
3 | /** @type {import('vite').UserConfig} */
4 | const config = {
5 | plugins: [sveltekit()]
6 | };
7 |
8 | export default config;
9 |
--------------------------------------------------------------------------------
/packages/vue-scenejs/.browserslistrc:
--------------------------------------------------------------------------------
1 | > 1%
2 | last 2 versions
3 |
--------------------------------------------------------------------------------
/packages/vue-scenejs/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 | # local env files
6 | .env.local
7 | .env.*.local
8 |
9 | # Log files
10 | npm-debug.log*
11 | yarn-debug.log*
12 | yarn-error.log*
13 |
14 | # Editor directories and files
15 | .idea
16 | .vscode
17 | *.suo
18 | *.ntvs*
19 | *.njsproj
20 | *.sln
21 | *.sw?
22 |
--------------------------------------------------------------------------------
/packages/vue-scenejs/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to this project will be documented in this file.
4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5 |
6 | ## [2.0.0-beta.11](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/compare/vue-scenejs@2.0.0-beta.8...vue-scenejs@2.0.0-beta.11) (2023-06-05)
7 |
8 |
9 | ### :mega: Other
10 |
11 | * publish packages ([97ba4e7](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/commit/97ba4e775018179c16b0e5c0035f5a3773b64722))
12 | * publish packages ([f76d778](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/commit/f76d7782ee508fc12f16d250ca0c925f81d2a0e1))
13 | * publish packages ([2f9e242](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/commit/2f9e242c926cb13672d7f6d9924ea7782fb69815))
14 |
15 |
16 |
17 | ## [2.0.0-beta.8](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/compare/vue-scenejs@2.0.0-beta.3...vue-scenejs@2.0.0-beta.8) (2023-05-21)
18 |
19 |
20 | ### :rocket: New Features
21 |
22 | * add modules for frameworks ([d1c173d](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/commit/d1c173d72efba70193fbbcf50d8e9e3edb2629ae))
23 |
24 |
25 | ### :bug: Bug Fix
26 |
27 | * fix frameworks' reactive props ([17f9538](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/commit/17f9538823dafad9e36673fe7cc5bfa9178a147e))
28 | * fix partial reactive props ([06f063a](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/commit/06f063acd979e265bee1e09b1971211b65a6aaec))
29 |
30 |
31 | ### :mega: Other
32 |
33 | * publish packages ([b328ba8](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/commit/b328ba8fbbf552d1d8048c280392be59f12da68b))
34 | * publish packages ([275e338](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/commit/275e338931d19f3a75faf4c7f0935eeb848f5a9e))
35 | * publish packages ([eb28736](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/commit/eb2873676adb0fedf18d1e5a52bfdce08552274a))
36 | * publish packages ([0e37841](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/commit/0e37841738e150d6deb13f501bb715421ab040aa))
37 | * publish packages ([002fc93](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/commit/002fc93c9536659b5db95527c019f1e3ad32a1f8))
38 |
39 |
40 |
41 | ## [2.0.0-beta.3](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/compare/vue-scenejs@2.0.0-beta.2...vue-scenejs@2.0.0-beta.3) (2022-12-26)
42 |
43 |
44 | ### :mega: Other
45 |
46 | * publish packages ([843ebf6](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/commit/843ebf6d483549c130db47499d69dd4825118798))
47 |
48 |
49 |
50 | ## 2.0.0-beta.2 (2022-12-21)
51 |
52 |
53 | ### :rocket: New Features
54 |
55 | * add vue-scenejs for scenejs 1.0.0 (#34) ([af2b8ea](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/commit/af2b8ea013c652470631f6dfe0b2b753cec6ad0a))
56 | * Support Vue 2 & Vue 3 frameworks ([a5a0665](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/commit/a5a066535781d7f690ffb904abf41f6256ebee62))
57 |
58 |
59 | ### :bug: Bug Fix
60 |
61 | * update modules ([30191b8](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/commit/30191b8e7c195de355d0c01fa9110d6fe0b3df3b))
62 |
63 |
64 | ### :mega: Other
65 |
66 | * apply lerna ([39520c3](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/commit/39520c38008399d7947684f7e443b9b1765e422b))
67 | * publish packages ([1f4a4f3](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/commit/1f4a4f3719f1789fb91c7e744f4bf8261751944f))
68 | * publish packages ([3b63fde](https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs/commit/3b63fde8232cdc6454a8d8fe1a42b6317d614036))
69 |
--------------------------------------------------------------------------------
/packages/vue-scenejs/demo/index.ts:
--------------------------------------------------------------------------------
1 | import { createApp } from 'vue';
2 | import App from './App.vue';
3 |
4 | createApp(App).mount('#app')
5 |
--------------------------------------------------------------------------------
/packages/vue-scenejs/demo/shims-vue.d.ts:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | declare module '*.vue' {
3 | import type { DefineComponent } from 'vue'
4 | const component: DefineComponent<{}, {}, any>
5 | export default component
6 | }
7 |
--------------------------------------------------------------------------------
/packages/vue-scenejs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-scenejs",
3 | "version": "2.0.0-beta.11",
4 | "lernaHelperReleaseType": "prerelease",
5 | "lernaHelperPublishTag": "latest",
6 | "description": "A Vue 3 Component that create JavaScript & CSS timeline-based animation with Scene.js.",
7 | "main": "./dist/scene.cjs.js",
8 | "module": "./dist/scene.esm.js",
9 | "sideEffects": false,
10 | "types": "declaration/index.d.ts",
11 | "keywords": [
12 | "vue",
13 | "vue3",
14 | "composition",
15 | "reactive",
16 | "composition",
17 | "use",
18 | "scene",
19 | "scene.js",
20 | "scenejs",
21 | "keyframes",
22 | "timeline",
23 | "animate",
24 | "animation",
25 | "css",
26 | "requestAnimationFrame",
27 | "motion"
28 | ],
29 | "scripts": {
30 | "serve": "vue-cli-service serve demo",
31 | "build": "rm -rf dist && rollup -c && npm run declaration",
32 | "declaration": "rm -rf declaration && tsc -p tsconfig.declaration.json",
33 | "lint": "vue-cli-service lint --no-fix"
34 | },
35 | "repository": {
36 | "type": "git",
37 | "url": "https://github.com/daybrush/scenejs/blob/master/packages/vue3-scenejs"
38 | },
39 | "author": "Daybrush",
40 | "bugs": {
41 | "url": "https://github.com/daybrush/scenejs/issues"
42 | },
43 | "homepage": "https://github.com/daybrush/scenejs",
44 | "files": [
45 | "./*",
46 | "dist/*"
47 | ],
48 | "dependencies": {
49 | "@cfcs/vue3": "^0.1.0",
50 | "scenejs": "~1.10.3"
51 | },
52 | "devDependencies": {
53 | "@daybrush/builder": "^0.2.0",
54 | "@vue/cli-plugin-typescript": "~4.5.0",
55 | "@vue/cli-service": "~4.5.0",
56 | "@vue/compiler-sfc": "^3.0.0",
57 | "rollup-plugin-vue": "^6.0.0",
58 | "tslib": "^2.3.1",
59 | "typescript": "^4.5.0",
60 | "vue": "^3.1.1"
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/packages/vue-scenejs/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | autoprefixer: {}
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/packages/vue-scenejs/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/packages/vue-scenejs/public/favicon.ico
--------------------------------------------------------------------------------
/packages/vue-scenejs/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | vue-moveable
9 |
10 |
11 |
12 | We're sorry but vue-moveable doesn't work properly without JavaScript enabled. Please enable it to continue.
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/packages/vue-scenejs/rollup.config.js:
--------------------------------------------------------------------------------
1 | const buildHelper = require("@daybrush/builder");
2 | const vuePlugin = require("rollup-plugin-vue");
3 |
4 | const defaultOptions = {
5 | sourcemap: true,
6 | input: "./src/index.ts",
7 | exports: "named",
8 | plugins: [
9 | vuePlugin(),
10 | ],
11 | external: {
12 | "vue": "Vue",
13 | },
14 | };
15 | module.exports = buildHelper([
16 | {
17 | ...defaultOptions,
18 | format: "es",
19 | output: "./dist/scene.esm.js",
20 | },
21 | {
22 | ...defaultOptions,
23 | format: "cjs",
24 | // input: "./src/index.umd.ts",
25 | exports: "named",
26 | output: "./dist/scene.cjs.js",
27 | },
28 | ]);
29 |
--------------------------------------------------------------------------------
/packages/vue-scenejs/src/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @namespace Vue3Scene
3 | */
4 | export * from "./useScene";
5 | export * from "./useSceneItem";
6 | export * from "./useFrame";
7 | export * from "./useNowFrame";
8 | export * from "scenejs";
9 |
--------------------------------------------------------------------------------
/packages/vue-scenejs/src/useFrame.ts:
--------------------------------------------------------------------------------
1 | import { VueReactiveAdapterResult, useReactive } from "@cfcs/vue3";
2 | import { FRAME_REACTIVE, FrameReactiveData } from "scenejs";
3 |
4 |
5 | /**
6 | * You can use reactive state and frame methods.
7 | * To access the state in Vue you need to add $ prefix.
8 | * @typedef
9 | * @memberof Vue3Scene
10 | * @see Frame
11 | * @extends Reactive.FrameReactiveState
12 | */
13 | export interface VueFrameResult extends VueReactiveAdapterResult { }
14 |
15 | /**
16 | * @memberof Vue3Scene
17 | * @param {Reactive.FrameReactiveData} - Can be used as frame, cssText, cssObject, etc.
18 | * @return - You can use Frame methods and cssText, cssObject, ...etc
19 | * @example
20 | * import { useFrame } from "vue-scenejs";
21 | *
22 | * const { cssText } = useFrame("text-align: center; transform: translate(10px, 10px);");
23 | *
24 | * console.log(cssText.value);
25 | */
26 | export function useFrame(props: FrameReactiveData): VueFrameResult {
27 | return useReactive({
28 | ...FRAME_REACTIVE,
29 | data: () => props,
30 | });
31 | }
32 |
--------------------------------------------------------------------------------
/packages/vue-scenejs/src/useNowFrame.ts:
--------------------------------------------------------------------------------
1 | import { VueReactiveAdapterResult, useReactive } from "@cfcs/vue3";
2 | import { SceneItem, NOW_FRAME_REACTIVE } from "scenejs";
3 |
4 |
5 | /**
6 | * To access the state in Vue you need to add $ prefix.
7 | * @typedef
8 | * @memberof Vue3Scene
9 | * @extends Vue3Scene.ReactFrameResult
10 | */
11 | export interface VueNowFrameResult extends VueReactiveAdapterResult { }
12 |
13 | /**
14 | * @memberof Vue3Scene
15 | * @param - item to get the current frame
16 | * @return - You can use Frame methods and cssText, cssObject, ...etc State
17 | * @example
18 | * import { useSceneItem, useNowFrame } from "vue-scenejs";
19 | *
20 | * const sceneItem = useSceneItem(...);
21 | * const { cssText } = useNowFrame(sceneItem);
22 | *
23 | * console.log(cssText.value);
24 | */
25 | export function useNowFrame(item: SceneItem): VueNowFrameResult {
26 | return useReactive({
27 | ...NOW_FRAME_REACTIVE,
28 | data: () => item,
29 | });
30 | }
31 |
--------------------------------------------------------------------------------
/packages/vue-scenejs/src/useScene.ts:
--------------------------------------------------------------------------------
1 | import { VueReactiveAdapterResult, useReactive } from "@cfcs/vue3";
2 | import { SceneOptions, SceneReactiveProps, SCENE_REACTIVE } from "scenejs";
3 |
4 |
5 | /**
6 | * To access the state in Vue you need to add $ prefix.
7 | * @typedef
8 | * @memberof Vue3Scene
9 | * @extends Reactive.AnimatorReactiveState
10 | */
11 | export interface VueSceneResult extends VueReactiveAdapterResult { }
12 |
13 |
14 | /**
15 | * @memberof Vue3Scene
16 | * @param {Reactive.SceneReactiveProps} - Items and properties that make up the scene
17 | * @param - Scene and Animator options
18 | * @return - You can use Scene methods and Animator State
19 | * @example
20 | * import { useScene, useNowFrame } from "vue-scenejs";
21 | *
22 | * const scene = useScene({ ... });
23 | * const { cssText } = useNowFrame(scene.getItem("a1"));
24 | *
25 | * console.log(cssText.value);
26 | */
27 | export function useScene(props?: SceneReactiveProps, options?: Partial): VueSceneResult {
28 | return useReactive({
29 | ...SCENE_REACTIVE,
30 | data() {
31 | return {
32 | props,
33 | options,
34 | };
35 | },
36 | });
37 | }
38 |
--------------------------------------------------------------------------------
/packages/vue-scenejs/src/useSceneItem.ts:
--------------------------------------------------------------------------------
1 | import { VueReactiveAdapterResult, useReactive } from "@cfcs/vue3";
2 | import { SCENE_ITEM_REACTIVE, SceneItemOptions, SceneItemReactiveProps } from "scenejs";
3 |
4 | /**
5 | * To access the state in Vue you need to add $ prefix.
6 | * @typedef
7 | * @memberof Vue3Scene
8 | * @extends Reactive.AnimatorReactiveState
9 | */
10 | export interface VueSceneItemResult extends VueReactiveAdapterResult { }
11 |
12 | /**
13 | * @memberof Vue3Scene
14 | * @param {Reactive.SceneItemReactiveProps} - Items and properties that make up the scene item
15 | * @param - SceneItem and Animator options
16 | * @return - You can use SceneItem methods and Animator State.
17 | * @example
18 | * import { useSceneItem, useNowFrame } from "vue-scenejs";
19 | *
20 | * const item = useSceneItem({ ... });
21 | * const { cssText } = useNowFrame(item);
22 | *
23 | * console.log(cssText.value);
24 | */
25 | export function useSceneItem(props?: SceneItemReactiveProps, options?: Partial) {
26 | return useReactive({
27 | ...SCENE_ITEM_REACTIVE,
28 | data: () => ({
29 | props,
30 | options,
31 | }),
32 | });
33 | }
34 |
--------------------------------------------------------------------------------
/packages/vue-scenejs/tsconfig.declaration.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig",
3 | "compilerOptions": {
4 | "removeComments": true,
5 | "declaration": true,
6 | "emitDeclarationOnly": true,
7 | "declarationDir": "declaration"
8 | },
9 | "include": [
10 | "src/**/*.ts",
11 | "src/**/*.tsx",
12 | "src/**/*.vue"
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/packages/vue-scenejs/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "esnext",
5 | "strict": true,
6 | "jsx": "preserve",
7 | "importHelpers": true,
8 | "moduleResolution": "node",
9 | "experimentalDecorators": true,
10 | "esModuleInterop": true,
11 | "allowSyntheticDefaultImports": true,
12 | "sourceMap": true,
13 | "baseUrl": ".",
14 | "types": [
15 | "webpack-env"
16 | ],
17 | "paths": {
18 | "@/*": [
19 | "src/*"
20 | ]
21 | },
22 | "lib": [
23 | "esnext",
24 | "dom",
25 | "dom.iterable",
26 | "scripthost"
27 | ]
28 | },
29 | "include": [
30 | "src/**/*.ts",
31 | "src/**/*.tsx",
32 | "src/**/*.vue",
33 | "tests/**/*.ts",
34 | "tests/**/*.tsx"
35 | ],
36 | "exclude": [
37 | "node_modules"
38 | ]
39 | }
40 |
--------------------------------------------------------------------------------
/packages/vue2-scenejs/.browserslistrc:
--------------------------------------------------------------------------------
1 | > 1%
2 | last 2 versions
3 |
--------------------------------------------------------------------------------
/packages/vue2-scenejs/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | env: {
4 | node: true
5 | },
6 | 'extends': [
7 | 'plugin:vue/essential',
8 | 'eslint:recommended',
9 | '@vue/typescript'
10 | ],
11 | rules: {
12 | 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
13 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
14 | },
15 | parserOptions: {
16 | parser: '@typescript-eslint/parser'
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/packages/vue2-scenejs/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 |
4 | # local env files
5 | .env.local
6 | .env.*.local
7 |
8 | # Log files
9 | npm-debug.log*
10 | yarn-debug.log*
11 | yarn-error.log*
12 |
13 | # Editor directories and files
14 | .idea
15 | .vscode
16 | *.suo
17 | *.ntvs*
18 | *.njsproj
19 | *.sln
20 | *.sw?
21 |
--------------------------------------------------------------------------------
/packages/vue2-scenejs/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to this project will be documented in this file.
4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5 |
6 | ## [1.0.0-beta.11](https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs/compare/vue2-scenejs@1.0.0-beta.8...vue2-scenejs@1.0.0-beta.11) (2023-06-05)
7 |
8 |
9 | ### :mega: Other
10 |
11 | * publish packages ([97ba4e7](https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs/commit/97ba4e775018179c16b0e5c0035f5a3773b64722))
12 | * publish packages ([f76d778](https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs/commit/f76d7782ee508fc12f16d250ca0c925f81d2a0e1))
13 | * publish packages ([2f9e242](https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs/commit/2f9e242c926cb13672d7f6d9924ea7782fb69815))
14 |
15 |
16 |
17 | ## [1.0.0-beta.8](https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs/compare/vue2-scenejs@1.0.0-beta.3...vue2-scenejs@1.0.0-beta.8) (2023-05-21)
18 |
19 |
20 | ### :rocket: New Features
21 |
22 | * add modules for frameworks ([d1c173d](https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs/commit/d1c173d72efba70193fbbcf50d8e9e3edb2629ae))
23 |
24 |
25 | ### :bug: Bug Fix
26 |
27 | * fix frameworks' reactive props ([17f9538](https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs/commit/17f9538823dafad9e36673fe7cc5bfa9178a147e))
28 | * fix partial reactive props ([06f063a](https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs/commit/06f063acd979e265bee1e09b1971211b65a6aaec))
29 |
30 |
31 | ### :mega: Other
32 |
33 | * publish packages ([b328ba8](https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs/commit/b328ba8fbbf552d1d8048c280392be59f12da68b))
34 | * publish packages ([275e338](https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs/commit/275e338931d19f3a75faf4c7f0935eeb848f5a9e))
35 | * publish packages ([eb28736](https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs/commit/eb2873676adb0fedf18d1e5a52bfdce08552274a))
36 | * publish packages ([0e37841](https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs/commit/0e37841738e150d6deb13f501bb715421ab040aa))
37 | * publish packages ([002fc93](https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs/commit/002fc93c9536659b5db95527c019f1e3ad32a1f8))
38 |
39 |
40 |
41 | ## [1.0.0-beta.3](https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs/compare/vue2-scenejs@1.0.0-beta.2...vue2-scenejs@1.0.0-beta.3) (2022-12-26)
42 |
43 |
44 | ### :mega: Other
45 |
46 | * publish packages ([843ebf6](https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs/commit/843ebf6d483549c130db47499d69dd4825118798))
47 |
48 |
49 |
50 | ## 1.0.0-beta.2 (2022-12-21)
51 |
52 |
53 | ### :rocket: New Features
54 |
55 | * Support Vue 2 & Vue 3 frameworks ([a5a0665](https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs/commit/a5a066535781d7f690ffb904abf41f6256ebee62))
56 |
57 |
58 | ### :bug: Bug Fix
59 |
60 | * update modules ([30191b8](https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs/commit/30191b8e7c195de355d0c01fa9110d6fe0b3df3b))
61 |
62 |
63 | ### :mega: Other
64 |
65 | * publish packages ([1f4a4f3](https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs/commit/1f4a4f3719f1789fb91c7e744f4bf8261751944f))
66 | * publish packages ([3b63fde](https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs/commit/3b63fde8232cdc6454a8d8fe1a42b6317d614036))
67 |
--------------------------------------------------------------------------------
/packages/vue2-scenejs/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Daybrush
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/packages/vue2-scenejs/demo/index.ts:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import VueCompositionAPI from '@vue/composition-api';
3 | import App from './App.vue';
4 |
5 | Vue.use(VueCompositionAPI);
6 | new Vue({
7 | render: (h: any) => h(App),
8 | }).$mount('#app');
9 |
--------------------------------------------------------------------------------
/packages/vue2-scenejs/demo/shims-vue.d.ts:
--------------------------------------------------------------------------------
1 | declare module "*.vue" {
2 | import Vue from "vue";
3 | export default Vue;
4 | }
5 |
--------------------------------------------------------------------------------
/packages/vue2-scenejs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue2-scenejs",
3 | "version": "1.0.0-beta.11",
4 | "lernaHelperReleaseType": "prerelease",
5 | "lernaHelperPublishTag": "latest",
6 | "description": "A Vue 2 Component that create JavaScript & CSS timeline-based animation with Scene.js.",
7 | "main": "./dist/scene.cjs.js",
8 | "module": "./dist/scene.esm.js",
9 | "sideEffects": false,
10 | "types": "declaration/index.d.ts",
11 | "keywords": [
12 | "vue",
13 | "vue2",
14 | "reactive",
15 | "use",
16 | "scene",
17 | "scene.js",
18 | "scenejs",
19 | "keyframes",
20 | "timeline",
21 | "animate",
22 | "animation",
23 | "css",
24 | "requestAnimationFrame",
25 | "motion"
26 | ],
27 | "scripts": {
28 | "serve": "vue-cli-service serve demo",
29 | "build": "rollup -c && npm run declaration",
30 | "declaration": "rm -rf declaration && tsc -p tsconfig.declaration.json",
31 | "lint": "vue-cli-service lint"
32 | },
33 | "repository": {
34 | "type": "git",
35 | "url": "https://github.com/daybrush/scenejs/blob/master/packages/vue2-scenejs"
36 | },
37 | "author": "Daybrush",
38 | "bugs": {
39 | "url": "https://github.com/daybrush/scenejs/issues"
40 | },
41 | "homepage": "https://github.com/daybrush/scenejs",
42 | "files": [
43 | "./*",
44 | "dist/*"
45 | ],
46 | "dependencies": {
47 | "@cfcs/vue2": "^0.1.0",
48 | "scenejs": "~1.10.3"
49 | },
50 | "devDependencies": {
51 | "@babel/core": "^7.12.10",
52 | "@daybrush/builder": "^0.2.0",
53 | "@typescript-eslint/parser": "^2.33.0",
54 | "@vue/cli-plugin-typescript": "~4.5.0",
55 | "@vue/cli-service": "~4.5.0",
56 | "@vue/composition-api": "^1.2.4",
57 | "@vue/eslint-config-airbnb": "^5.0.2",
58 | "@vue/eslint-config-prettier": "^6.0.0",
59 | "@vue/eslint-config-typescript": "^5.0.2",
60 | "@vue/test-utils": "^1.0.3",
61 | "babel-eslint": "^10.1.0",
62 | "babel-loader": "^8.2.2",
63 | "print-sizes": "^0.1.0",
64 | "rollup-plugin-vue": "^5.1.9",
65 | "tslib": "^2.3.1",
66 | "typescript": "^4.1.6",
67 | "vue": "2.6.11",
68 | "vue-template-compiler": "2.6.11"
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/packages/vue2-scenejs/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | autoprefixer: {}
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/packages/vue2-scenejs/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daybrush/scenejs/da1b4eb7c045d3f7133d2bb63fe29d1080be9639/packages/vue2-scenejs/public/favicon.ico
--------------------------------------------------------------------------------
/packages/vue2-scenejs/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | vue-guides
9 |
10 |
11 |
12 | We're sorry but vue-guides doesn't work properly without JavaScript enabled. Please enable it to continue.
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/packages/vue2-scenejs/rollup.config.js:
--------------------------------------------------------------------------------
1 | const buildHelper = require("@daybrush/builder");
2 | const vuePlugin = require("rollup-plugin-vue");
3 |
4 | const defaultOptions = {
5 | sourcemap: true,
6 | input: "./src/index.ts",
7 | exports: "named",
8 | plugins: [
9 | vuePlugin(),
10 | ],
11 | external: {
12 | "vue": "Vue",
13 | },
14 | };
15 | module.exports = buildHelper([
16 | {
17 | ...defaultOptions,
18 | format: "es",
19 | output: "./dist/scene.esm.js",
20 | },
21 | {
22 | ...defaultOptions,
23 | format: "cjs",
24 | // input: "./src/index.umd.ts",
25 | exports: "named",
26 | output: "./dist/scene.cjs.js",
27 | },
28 | ]);
29 |
--------------------------------------------------------------------------------
/packages/vue2-scenejs/src/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @namespace Vue2Scene
3 | */
4 | export * from "./useScene";
5 | export * from "./useSceneItem";
6 | export * from "./useFrame";
7 | export * from "./useNowFrame";
8 | export * from "scenejs";
9 |
--------------------------------------------------------------------------------
/packages/vue2-scenejs/src/useFrame.ts:
--------------------------------------------------------------------------------
1 | import { VueReactiveAdapterResult, useReactive } from "@cfcs/vue2";
2 | import { FRAME_REACTIVE, FrameReactiveData } from "scenejs";
3 |
4 |
5 | /**
6 | * You can use reactive state and frame methods.
7 | * To access the state in Vue you need to add $ prefix.
8 | * @typedef
9 | * @memberof Vue2Scene
10 | * @see Frame
11 | * @extends Reactive.FrameReactiveState
12 | */
13 | export interface VueFrameResult extends VueReactiveAdapterResult { }
14 |
15 | /**
16 | * @memberof Vue2Scene
17 | * @param {Reactive.FrameReactiveData} - Can be used as frame, cssText, cssObject, etc.
18 | * @return - You can use Frame methods and cssText, cssObject, ...etc
19 | * @example
20 | * import { useFrame } from "vue2-scenejs";
21 | *
22 | * const { cssText } = useFrame("text-align: center; transform: translate(10px, 10px);");
23 | *
24 | * console.log(cssText.value);
25 | */
26 | export function useFrame(props: FrameReactiveData): VueFrameResult {
27 | return useReactive({
28 | ...FRAME_REACTIVE,
29 | data: () => props,
30 | });
31 | }
32 |
--------------------------------------------------------------------------------
/packages/vue2-scenejs/src/useNowFrame.ts:
--------------------------------------------------------------------------------
1 | import { VueReactiveAdapterResult, useReactive } from "@cfcs/vue2";
2 | import { SceneItem, NOW_FRAME_REACTIVE } from "scenejs";
3 |
4 |
5 | /**
6 | * To access the state in Vue you need to add $ prefix.
7 | * @typedef
8 | * @memberof Vue2Scene
9 | * @extends Vue2Scene.ReactFrameResult
10 | */
11 | export interface VueNowFrameResult extends VueReactiveAdapterResult { }
12 |
13 | /**
14 | * @memberof Vue2Scene
15 | * @param - item to get the current frame
16 | * @return - You can use Frame methods and cssText, cssObject, ...etc State
17 | * @example
18 | * import { useSceneItem, useNowFrame } from "vue2-scenejs";
19 | *
20 | * const sceneItem = useSceneItem(...);
21 | * const { cssText } = useNowFrame(sceneItem);
22 | *
23 | * console.log(cssText.value);
24 | */
25 | export function useNowFrame(item: SceneItem): VueNowFrameResult {
26 | return useReactive({
27 | ...NOW_FRAME_REACTIVE,
28 | data: () => item,
29 | });
30 | }
31 |
--------------------------------------------------------------------------------
/packages/vue2-scenejs/src/useScene.ts:
--------------------------------------------------------------------------------
1 | import { VueReactiveAdapterResult, useReactive } from "@cfcs/vue2";
2 | import { SceneOptions, SceneReactiveProps, SCENE_REACTIVE } from "scenejs";
3 |
4 |
5 | /**
6 | * To access the state in Vue you need to add $ prefix.
7 | * @typedef
8 | * @memberof Vue2Scene
9 | * @extends Reactive.AnimatorReactiveState
10 | */
11 | export interface VueSceneResult extends VueReactiveAdapterResult { }
12 |
13 |
14 | /**
15 | * @memberof Vue2Scene
16 | * @param {Reactive.SceneReactiveProps} - Items and properties that make up the scene
17 | * @param - Scene and Animator options
18 | * @return - You can use Scene methods and Animator State
19 | * @example
20 | * import { useScene, useNowFrame } from "vue2-scenejs";
21 | *
22 | * const scene = useScene({ ... });
23 | * const { cssText } = useNowFrame(scene.getItem("a1"));
24 | *
25 | * console.log(cssText.value);
26 | */
27 | export function useScene(props?: SceneReactiveProps, options?: Partial): VueSceneResult {
28 | return useReactive({
29 | ...SCENE_REACTIVE,
30 | data() {
31 | return {
32 | props,
33 | options,
34 | };
35 | },
36 | });
37 | }
38 |
--------------------------------------------------------------------------------
/packages/vue2-scenejs/src/useSceneItem.ts:
--------------------------------------------------------------------------------
1 | import { VueReactiveAdapterResult, useReactive } from "@cfcs/vue2";
2 | import { SCENE_ITEM_REACTIVE, SceneItemOptions, SceneItemReactiveProps } from "scenejs";
3 |
4 | /**
5 | * To access the state in Vue you need to add $ prefix.
6 | * @typedef
7 | * @memberof Vue2Scene
8 | * @extends Reactive.AnimatorReactiveState
9 | */
10 | export interface VueSceneItemResult extends VueReactiveAdapterResult { }
11 |
12 | /**
13 | * @memberof Vue2Scene
14 | * @param {Reactive.SceneItemReactiveProps} - Items and properties that make up the scene item
15 | * @param - SceneItem and Animator options
16 | * @return - You can use SceneItem methods and Animator State.
17 | * @example
18 | * import { useSceneItem, useNowFrame } from "vue2-scenejs";
19 | *
20 | * const item = useSceneItem({ ... });
21 | * const { cssText } = useNowFrame(item);
22 | *
23 | * console.log(cssText.value);
24 | */
25 | export function useSceneItem(props?: SceneItemReactiveProps, options?: Partial) {
26 | return useReactive({
27 | ...SCENE_ITEM_REACTIVE,
28 | data: () => ({
29 | props,
30 | options,
31 | }),
32 | });
33 | }
34 |
--------------------------------------------------------------------------------
/packages/vue2-scenejs/tsconfig.declaration.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig",
3 | "compilerOptions": {
4 | "removeComments": true,
5 | "declaration": true,
6 | "emitDeclarationOnly": true,
7 | "declarationDir": "declaration"
8 | },
9 | "include": [
10 | "src/**/*.ts",
11 | "src/**/*.tsx",
12 | ],
13 | }
14 |
--------------------------------------------------------------------------------
/packages/vue2-scenejs/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "esnext",
5 | "strict": true,
6 | "jsx": "preserve",
7 | "importHelpers": true,
8 | "moduleResolution": "node",
9 | "experimentalDecorators": true,
10 | "esModuleInterop": true,
11 | "allowSyntheticDefaultImports": true,
12 | "sourceMap": true,
13 | "baseUrl": ".",
14 | "types": [
15 | "webpack-env"
16 | ],
17 | "paths": {
18 | "@/*": [
19 | "src/*"
20 | ]
21 | },
22 | "lib": [
23 | "esnext",
24 | "dom",
25 | "dom.iterable",
26 | "scripthost"
27 | ]
28 | },
29 | "include": [
30 | "src/**/*.ts",
31 | "src/**/*.tsx",
32 | "src/**/*.vue",
33 | "tests/**/*.ts",
34 | "tests/**/*.tsx"
35 | ],
36 | "exclude": [
37 | "node_modules"
38 | ]
39 | }
40 |
--------------------------------------------------------------------------------
/static/scripts/custom.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | window.dataLayer = window.dataLayer || [];
3 | function gtag() { dataLayer.push(arguments); }
4 | gtag('js', new Date());
5 |
6 | gtag('config', 'G-TRBNXHQ0ZF');
7 | var script = document.createElement("script");
8 |
9 | script.src = "https://www.googletagmanager.com/gtag/js?id=G-TRBNXHQ0ZF";
10 |
11 | document.body.appendChild(script);
12 | })();
13 |
--------------------------------------------------------------------------------