gpt4 book ai didi

javascript - 从外部元素控制 Flexslider。

转载 作者:行者123 更新时间:2023-12-03 21:46:48 27 4
gpt4 key购买 nike

我有一个 Flexislider,我想从元素外部控制它。我试过这个:

var myslider = $('.slider').flexslider({
animation: 'slide'
});

$('button').click(function () {
myslider.flexAnimate(3)    //Function: Move slider - (target, pause) parameters
});

但是返回TypeError: Object [object Object] has no method 'flexAnimate'

然后我偶然发现了这个线程(https://github.com/woothemes/FlexSlider/issues/125),它表明这是正确的方法:

$('button').click(function () {
myslider.flexslider(3)
});

但是我不知道如何指定动画的速度。我希望仅针对该事件进行即时更改。

我想我想知道如何从 slider 元素外部访问文档中提到的 slider API

slider                        //Object: The slider element itself
slider.container //Object: The ul.slides within the slider
slider.slides //Object: The slides of the slider
slider.count //Int: The total number of slides in the slider
slider.currentSlide //Int: The slide currently being shown
slider.animatingTo //Int: Useful in .before(), the slide currently animating to
slider.animating //Boolean: is slider animating?
slider.atEnd //Boolean: is the slider at either end?
slider.manualPause //Boolean: force slider to stay paused during pauseOnHover event
slider.controlNav //Object: The slider controlNav
slider.directionNav //Object: The slider directionNav
slider.controlsContainer //Object: The controlsContainer element of the slider
slider.manualControls //Object: The manualControls element of the slider
slider.flexAnimate(target) //Function: Move slider - (target, pause) parameters
slider.pause() //Function: Pause slider slideshow interval
slider.resume() //Function: Resume slider slideshow interval
slider.canAdvance(target) //Function: returns boolean if slider can advance - (target) parameter
slider.getTarget(dir) //Function: get target given a direction - "next" or "prev" parameter

最佳答案

您可以像这样访问 slider 对象:

var exampleSlider = $('#slider').data('flexslider');
// now you can access all the methods for example flexAnimate
exampleSlider.flexAnimate(..);

如上所述,您可以在 API 描述中找到此信息 https://github.com/woothemes/FlexSlider (源代码行:https://github.com/woothemes/FlexSlider/blob/master/jquery.flexslider.js#L674)

关于javascript - 从外部元素控制 Flexslider。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11859102/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com