jsor / jcarousel

Riding carousels with jQuery.
https://sorgalla.com/jcarousel/
MIT License
1.99k stars 734 forks source link

hasNext/Prev with center option #746

Closed aless133 closed 9 years ago

aless133 commented 9 years ago

I this there should be something like that in hasNext() (this.options('center') && this.index(this._target) < end) ||

        return end >= 0 && !this.underflow &&
            ((wrap && wrap !== 'first') ||
                (this.index(this._last) < end) ||
                (this.options('center') && this.index(this._target) < end) ||
                (this.tail && !this.inTail)) ? true : false;

and in hasPrev (this.options('center') && this.index(this._target) >0) ||

        return this.items().length > 0 && !this.underflow &&
            ((wrap && wrap !== 'last') ||
                (this.index(this._first) > 0) ||
                (this.options('center') && this.index(this._target) >0) ||
                (this.tail && this.inTail)) ? true : false;
jsor commented 9 years ago

Can you elaborate what problem this code solves?

aless133 commented 9 years ago

In "center mode" visibility doesn't matter on activity on next/prev controls. Only current target matter. Btw, I've end up with this, because of .underflow :

        if (this.options('center'))
            return this.index(this._target) <end;
        else
            return 
            (end >= 0 && !this.underflow &&
            ((wrap && wrap !== 'first') ||
                (this.index(this._last) < end) ||
                (this.tail && !this.inTail))) ? true : false; 
jsor commented 9 years ago

Got it. Fixed in 31e28db. Thanks!