📹 Video
- Start by creating a folder for your new project, then add 🤔parcel bundler as a dev dependency.
yarn add -D parcel-bundler
- Now you have a package.json where you can add a script called dev that will use parcel to run the index.html file.
{
"scripts": {
"dev": "parcel index.html"
},
"devDependencies": {
"parcel-bundler": "version#"
}
}
-
Create an index.html file, a default template ( ! tab inside index.html ) is sufficient.
-
You can now run the command.
yarn dev
- Go to the corresponding url (defaults to http://localhost:1234) to see your project.
- Stop your server before adding index.js script.
- Create an index.js file and add a script tag to index.html to bring it in.
<script src='./index.js'></script>
- Now you can restart your server after adding index.js script.
- You can now test your js by adding some
innerHTML
to thedocument.body
.
document.body.innerHTML = `<h1>Hi</h1>`
- Now import from 'gsap' at the top of index.js.
import { TweenMax } from 'gsap'
- Parcel bundler will automatically add the dependency, if you aren't using parcel-bundler then run
yarn add gsap
from your terminal to install greensock.
- You can now create an element in index.html, and then run a gsap animation in index.js.
TweenMax.to("element", duration, {properties})
Take a look at your animation in the browser.