English 中文(简体)
Making Making
原标题:Making carousel not infinitely scroll

我写了这一无限的雕刻,我不禁要问,什么是最佳的方式来进行非无限的 s。

现在,用户具体说明他们想在时间(南lide)上看到多少件。 因此,用户基本上在右arrow上点击,它使用称作<代码>prevLoop或nextLoop的方法。 其中任何一个基本只是将特定要素的数量拉开,并将其移至<代码><></ul>。

我已经走过了这一路,但现在我试图提出放弃无限滚动的选择(例如,只显示名单上的物品,一旦你到达每一方的末尾,就会阻止叫前洛普/特洛普。

我的想法基本是,形成一个要求无限的变量。 在任何一个点击功能(rightClick()和leftClick()内,检查是否确实有效。 如果是的话,采用正常的滚动代码。 否则,我的想法是:将<代码><ul>内发现的、在<代码>numElements内所含要素数目计算在内,通过每点点点点计算一个计算变量,并检查该数值是否与核心要素相同。 如果是<代码>>numElements,那么我就阻止了这两种功能的消化。 我感到,这样做会很快地发生迷惑。

具体如下:

    var count = numElements;
    function rightClick() {
    var cfirst = container.find( li ).first(), //the current first element
        tomove = cfirst.nextLoop(numSlide - 1, true), //the elements that need to move
        nfirst = tomove.last().nextLoop(1, false); //the new first element

    /*
       Pretend we currently have [A, B, C, D, E, F, G, H, I] and numSlide is 3
       cfirst === [A]
       tomove === [A, B, C]
       nfirst === [D]
    */

    var indent = cfirst.offset().left - nfirst.offset().left;

    if (infinite) {
    ul.not( :animated ).animate({ // not:animated makes sure we only get one @ a time
         left : indent
    },  fast , function() {
        tomove.appendTo(ul); //Move them to the end of the UL
        ul.css({ // left indent of ul
             left : 0
        });
    });
} else {
     // Infinite is turned off, handle it in here
    count = count -1;
    // Animate numElements - numSlide
}
}

是否有任何其他想法? 在这里,这是一场工作:

http://jsfiddle.net/someprimetime/AYfhn/

最佳回答
问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签