
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

Why or when should one choose Tailwind over Bootstrap? :slight_smile:
New

What does svelte offer that React or Vue doesn’t?
New

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 mean, when you render all the HTML at the server side and the data is sent through HTTP requests, except only if some tiny things are d...
New

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 ...
New

Hello All,
How would you implement a navigation system in React Native? Could not find a way so I ask the community can someone help me ...
New

I have done small amounts of programming for IOS and for Android, but now I need to create something that works with both.
What are the ...
New

Hello. So unexperienced frontend dev here. Basically, 3 or 4 months ago I started working on a project and I committed the capital sin of...
New

Hello, I am new and trying to build my first app. So far, everything was going okay, but now I’m stuck and don’t know how to proceed. May...
New
Other popular topics

Reading something? Working on something? Planning something? Changing jobs even!?
If you’re up for sharing, please let us know what you’...
New

I’ve been hearing quite a lot of comments relating to the sound of a keyboard, with one of the most desirable of these called ‘thock’, he...
New

Do the test and post your score :nerd_face:
:keyboard:
If possible, please add info such as the keyboard you’re using, the layout (Qw...
New

Hello content creators! Happy new year. What tech topics do you think will be the focus of 2021? My vote for one topic is ethics in tech...
New

Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
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
Dmitry Zinoviev
@aqsaqal
Today we’re putting our spotlight on Dmitry Zinoviev, author of Data Science Essentials in ...
New

Author Spotlight
Jamis Buck
@jamis
This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
New

zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig.
General-purpose programming language and toolchain for maintaini...
New
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /ruby
- /wasm
- /erlang
- /phoenix
- /keyboards
- /rails
- /js
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /emacs
- /haskell
- /java
- /onivim
- /svelte
- /typescript
- /crystal
- /c-plus-plus
- /kotlin
- /tailwind
- /gleam
- /ocaml
- /react
- /elm
- /flutter
- /vscode
- /ash
- /opensuse
- /centos
- /php
- /deepseek
- /html
- /zig
- /scala
- /textmate
- /sublime-text
- /lisp
- /nixos
- /debian
- /react-native
- /agda
- /kubuntu
- /arch-linux
- /revery
- /django
- /ubuntu
- /spring
- /manjaro
- /nodejs
- /diversity
- /lua
- /c
- /julia
- /slackware
- /markdown