Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

How to have animation on scroll on Grav?

first-time

Started by Patrick D. 6 years ago · 7 replies · 1583 views
6 years ago

Im new to grav, can any body help me make a website like this on grav?
http://the-goonies.webflow.io/

I want to be able to incorporate animation on scroll for website using grav. Im very open to tutorials and etc. Please help me, thank you!

6 years ago

Thanks @AlexMart sorry for the late reply. Ill check it out this week. Thanks again for sending the documentation and tutorial video.

6 years ago

Hey @AlexMart by any chance do you have videos or links of integrating GSAP onto grav? Im really new to both tbh and Im not too sure how to link them up together. If you could direct/help on how to set this one up thatd be really great.

6 years ago

Hi @pjy
In order to make gsap + scrolltrigger works in your grav project, you have to integrate the javascript files into your partials/base.html.twig. Here is the way of how I integrate them on my projects.

1) create of modify your javascript block in your partials/base.html.twig. (I suppose your custom javascript file is called app.js and is located in the your-theme/js folder). Make sure to respect the right order. First the main gsap file, then the scrolltrigger file and then your custom javascript file.

TWIG
   {% block javascripts %}          
        {% do assets.addJs('https://cdnjs.cloudflare.com/ajax/libs/gsap/3.4.2/gsap.min.js',{group:'bottom'}, 100) %}
        {% do assets.addJs('https://cdnjs.cloudflare.com/ajax/libs/gsap/3.4.2/ScrollTrigger.min.js',{group:'bottom'}, 100) %}           
       {% do assets.addJs('theme://js/app.js',{group:'bottom'}, 100) %}
    {% endblock %}

2) Then just before the </body> tag, add the following lines to execute the javascript files from the group bottom

TWIG
    {% block bottom %} 
       {{ assets.js('bottom')|raw }}
    {% endblock %}
    </body>

3) That's it, now gsap and scrolltrigger are ready to use. You can now add your custom javascript in the app.js file like in the tutorial video

Hope it helps!

6 years ago

Hey @AlexMart @pjy do you have any sample projects or source codes I could download so I can have reference on how you handle coding the pages? Im currently coding it using plain HTML on a grav page.

image|654x500

If you could direct me to a grav project that uses gsap already, that would really help me a bunch in understanding how it works together.

6 years ago

hey @Joshua

I suggest you to have a look a the grav documentation here :

https://learn.getgrav.org/16

You'll find how grav works with markdown files and twig templates. The power of grav is to use template file (twig) to put your html in a dynamic way and rarely "hard code" your code.

As I can see in your screenshot you try to add differents divs in the same page, so maybe you have to consider using modular pages. You can find documentation here :

https://learn.getgrav.org/16/content/modular

Those are the basis of grav. Start understanding how it works first. You can use a pre-made skeleton, with modular pages, like this one and try playing with the markdown files and twig template to change the site content :

https://github.com/getgrav/grav-skeleton-onepage-site

Unfortunately there's no grav projects with gsap already installed.

Cheers,

Alex

6 years ago

Hello,

An other solution.

I've done some animations on scroll on my personnal website.
It's nothing fancy, only some background-color changes, or background scaling.

I didn't use GSAP for this, only plain javascript.
I'm checking if an element is about to be in view, I add a class with some css transition and it's done for the js.

In my templates, I'm adding the class that the js is looking for.

Would that be enough for your case or do you need a more complex solution ?

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 3 days ago
2 70 5 hours ago
General · by pamtbaau, 10 hours ago
1 45 10 hours ago
General · by Andy Miller, 22 hours ago
0 43 22 hours ago
General · by Marcel, 12 months ago
6 341 4 days ago
General · by Duc , 5 days ago
3 35 5 days ago