
WiseDan
Gsap.js - how to load content in my home page when user scrolling?
hi everybody , am new in gsap.js
so i wanted load content in my home page when user scrolling , but
since am reading the documentation , when i include the cdn link , nothing is happen in the page like ( gsap.to(“.box”, { x:200, backgroundColor: “blue” })
please help with great example using gsap.js with cdn in your projet and have all done in the browser !!
Most Liked

gulshan212
Well, you can just copy the below code for getting what you are looking for.
<!DOCTYPE html>
<html>
<head>
<title>GSAP Scroll Animation Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.8.0/gsap.min.js"></script>
<style>
body {
height: 200vh; /* To make the page scrollable */
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
}
.box {
width: 100px;
height: 100px;
background-color: red;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<div class="box"></div>
<script>
<script>
// Wait for the DOM to be ready
document.addEventListener("DOMContentLoaded", function() {
// GSAP animation
gsap.to(".box", {
x: 200,
backgroundColor: "blue",
duration: 1, // Animation duration in seconds
scrollTrigger: {
trigger: ".box", // Element that triggers the animation
start: "top center", // Animation starts when this point of the element is at the top center of the viewport
end: "bottom center", // Animation ends when this point of the element is at the bottom center of the viewport
scrub: true, // Smoothly scrubs the animation as you scroll
},
});
});
</script>
</script>
</body>
</html>
Thanks
1
Popular Frontend topics

I have a sveltekit project that is using GoTrue library for authentication. In development mode (npm run dev) everything works but when I...
New

What is the best course of front end (live webinars or recorded)? So I already have basic understanding of HTML CSS JS and React but I wa...
New

I’m working with a designer who created a design in Photoshop. I am mostly a Node.js and Android dev, but when I have worked with designe...
New

In Elixir I love to use the library GitHub - sasa1977/boundary: Manage and restrain cross-module dependencies in Elixir projects to enfor...
New

Background
I have a a fresh umbrella project with a Phoenix app inside. To create the app I used the following commands:
mix new test_a...
New

I’m currently working on a JavaScript project that involves converting user-supplied text to numbers. Dealing with different areas and th...
New

Background
I have a custom component in my LiveView, which is basically a group of checkboxes.
I want to add a new attribute to my custo...
New

Hi all,
Anybody knows how to do this menu animation?
(from BBVA APP, they have the same for both android and iOS app).
Is it custom?...
New

First time building an app. It will run for Android and also for iPhone 15 but will not for iPod. Not sure why or where to even begin. ...
New

I have the following HTML structure, which is dynamically rendered from a Sightly (HTL) page in a new AEM component we’re building, so I ...
New
Other popular topics

I’ve been really enjoying obsidian.md:
It is very snappy (even though it is based on Electron). I love that it is all local by defaul...
New

Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New

On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a ...
New

I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New

The V Programming Language
Simple language for building maintainable programs
V is already mentioned couple of times in the forum, but I...
New

Seems like a lot of people caught it - just wondered whether any of you did?
As far as I know I didn’t, but it wouldn’t surprise me if I...
New

Saw this on TikTok of all places! :lol:
Anyone heard of them before?
Lite:
New

This is going to be a long an frequently posted thread.
While talking to a friend of mine who has taken data structure and algorithm cou...
New

Author Spotlight
James Stanier
@jstanier
James Stanier, author of Effective Remote Work , discusses how to rethink the office as we e...
New

A Brief Review of the Minisforum V3 AMD Tablet.
Update: I have created an awesome-minisforum-v3 GitHub repository to list information fo...
New
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /rails
- /js
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /ash
- /vscode
- /opensuse
- /centos
- /php
- /deepseek
- /html
- /zig
- /scala
- /debian
- /nixos
- /lisp
- /agda
- /sublime-text
- /react-native
- /textmate
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /django
- /spring
- /manjaro
- /diversity
- /lua
- /nodejs
- /c
- /julia
- /slackware
- /neovim