Jump to content
Search Community

My slide gallery is not working

Masha555 test
Moderator Tag

Recommended Posts

I tried to make a gallery following the following example:

<section>
    <h1>THIS  ISMY FIRST SLIDE ANIMATION</h1>
</section>
<section>
    <h1>GREAT THAT IT  SWORKING</h1>
</section>
<section>
    <h1>SCROLL MORE TO SEE MORE</h1>
</section>
<section>
    <h1>LOVING  THEIMAGES</h1>
</section>
<section>
    <h1>NICE, RIGHT?</h1>
</section> 

import { Component, OnInit } from '@angular/core';
import { gsap } from 'gsap';
import { ScrollTrigger } from 'gsap/all';

@Component({
 selector: 'app-slider',
 templateUrl: './slider.component.html',
 styleUrls: ['./slider.component.css']
})
export class SliderComponent implements OnInit {

 constructor() { }
 ngOnInit() {
 // Register the ScrollTrigger with gsap
 gsap.registerPlugin(ScrollTrigger);

 //Loop over all the sections and set animations
 gsap.utils.toArray("section").forEach((section: any, i) => {

 // Give the backgrounds some random images
 section.style.backgroundImage = `url(https://picsum.photos/${innerWidth}/${innerHeight}?random=${i})`;


 gsap.to(section, {
 scrollTrigger: {
 // Trigger the animation as soon as the section comes into view
 trigger: section,
 
 // Pin the section to give a feeling like slide for next section
 pin: true,

 // Remove the extra pin space added by default
 pinSpacing: false
 }
 });
 });
 }
} 

No CSS needs to be added.

 

But my code doesn't work :(  Please help me find the error   My code

 

Working demo of the author of the lesson

 

Link to comment
Share on other sites

Hi,

 

I think the issue could be more related to actual CSS than anything else. Take a look at these links:

https://developer.mozilla.org/en-US/docs/Web/CSS/background-size

https://developer.mozilla.org/en-US/docs/Web/CSS/background-position

https://developer.mozilla.org/en-US/docs/Web/CSS/background-repeat

 

Hopefully this helps.

Happy Tweening!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...