Then I have a content slider
Each item has a square in which theat items offset in the slider Such as
like
& lt; Div id = "slider" & gt; & Lt; Div class = "item item-number -1" & gt; & Lt; / Div & gt; & Lt; Div class = "item item-number-2" & gt; & Lt; / Div & gt; & Lt; Div class = "item item-number -3" & gt; & Lt; / Div & gt; & Lt; / Div & gt;
And this is a round slider, after the last item it shows the first object again
So I added custom indicators to the slider on top, but most Contrast slider for every 4 items in each indicator slider
For example, when I have 1-4 items 1 is ancillary, when there are 1-8 items, I have 2 indicators When I have 3 indicators in 1-12 items
That is why I am an active class. Ihn user sliding starts to add correct indicator
$ (document) .on ('click', '.prev, .next', function () {var p = $ (This) .parents ('# slider'); var it = p.find ('. Item: first'); var offset = number (this is 'et.' ('Class'). Partition ('') .pop ('Item-num-', '')); var indicator / number; if (offset = 4) indicator = 1 = number; other indicator_number = ?; $ ('.inidicator'). Eq (Indicator_number) .addClass ("active");})
I want this part indicator_number =? ;
I want a formula to find the correct indicator when the current index is larger than the offset 4
Simple arithmetic you should do what you want:
indicator_number = mathematics.flur ((offset - 1) / 4) + 1);
Offset - 1
: Obtain the zero based index of the current slide.
/ 4
: Split + 1
: Convert the result to a non-zero based index Math.floor
: in a whole number Convert
No comments:
Post a Comment