Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to autoplay horizontal slides #102

Closed
zeroseisdesign opened this issue Apr 19, 2022 · 2 comments
Closed

How to autoplay horizontal slides #102

zeroseisdesign opened this issue Apr 19, 2022 · 2 comments

Comments

@zeroseisdesign
Copy link

I was trying with this: https://alvarotrigo.com/fullPage/help/how-to-autoplay-horizontal-slides-in-fullpage-js/
but Angular doesn't find the name 'fullpage_api' in this code adding in my component and can't compile:

`
// fullpage options
licenseKey: 'MY_LICENSE',
anchors: ['one', 'two'],
navigation:false,
slidesNavigation: true,
verticalCentered:false,
animateAnchor:false,
autoScrolling:false,
bigSectionsDestination:'top',
fitToSection:false,
paddingTop:69,
controlArrows: false,
var g_interval: any;
// for more details on config options please visit fullPage.js docs
this.config = {

afterLoad: function (origin: any, destination: any, direction: any) {
clearInterval(g_interval);

const lapse = 1000;

const shouldAutoPlay = destination.item.hasAttribute('data-auto');

const hasSlides = destination.item.querySelectorAll('.fp-slides').length;

if(shouldAutoPlay && hasSlides){
g_interval = setInterval(function () {
//here is the bug
fullpage_api.moveSlideRight();
}, lapse);
}
},

};`
image

The const lapse seems to work, , but every second it shows this error:
TypeError: undefined is not an object (evaluating 'this.fullpage_api.moveSlideRight')

Any idea about configure this code to work in Angular?

Thanks in advance

@zeroseisdesign
Copy link
Author

I have found the solution, now it works:

`afterLoad: (origin: any, destination: any, direction: any) => {
clearInterval(g_interval);

    // 1000 milliseconds lapse
    const lapse = 3000;
    
    const shouldAutoPlay = destination.item.hasAttribute('data-auto');

    const hasSlides = destination.item.querySelectorAll('.fp-slides').length;
    
    if(shouldAutoPlay && hasSlides){
      g_interval = setInterval( () => {
        this.fullpage_api.moveSlideRight();
      }, lapse);
    }
  },`

@alvarotrigo
Copy link
Owner

Glad you did! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants