Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bootstrap
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
bootstrap
Commits
373a5418
Commit
373a5418
authored
Jan 21, 2012
by
Jacob Thornton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ability to cycle carousel to a particular frame
parent
6e490628
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
5 deletions
+29
-5
docs/javascript.html
docs/javascript.html
+2
-0
js/bootstrap-carousel.js
js/bootstrap-carousel.js
+27
-5
No files found.
docs/javascript.html
View file @
373a5418
...
...
@@ -1323,6 +1323,8 @@ $('.myCarousel').carousel({
<p>
Cycles through the carousel items from left to right.
</p>
<h4>
.carousel('pause')
</h4>
<p>
Stops the carousel from cycling through items.
</p>
<h4>
.carousel(number)
</h4>
<p>
Cycles the carousel to a particular frame (0 based, similar to an array).
</p>
<h4>
.carousel('prev')
</h4>
<p>
Cycles to the previous item.
</p>
<h4>
.carousel('next')
</h4>
...
...
js/bootstrap-carousel.js
View file @
373a5418
...
...
@@ -38,6 +38,27 @@
return
this
}
,
to
:
function
(
pos
)
{
var
$active
=
this
.
$element
.
find
(
'
.active
'
)
,
children
=
$active
.
parent
().
children
()
,
activePos
=
children
.
index
(
$active
)
,
that
=
this
if
(
pos
>
(
children
.
length
-
1
)
||
pos
<
0
)
return
if
(
this
.
sliding
)
{
return
this
.
$element
.
one
(
'
slid
'
,
function
()
{
that
.
to
(
pos
)
})
}
if
(
activePos
==
pos
)
{
return
this
.
pause
().
cycle
()
}
return
this
.
slide
(
pos
>
activePos
?
'
next
'
:
'
prev
'
,
$
(
children
[
pos
]))
}
,
pause
:
function
()
{
clearInterval
(
this
.
interval
)
return
this
...
...
@@ -53,9 +74,9 @@
return
this
.
slide
(
'
prev
'
)
}
,
slide
:
function
(
type
)
{
,
slide
:
function
(
type
,
next
)
{
var
$active
=
this
.
$element
.
find
(
'
.active
'
)
,
$next
=
$active
[
type
]()
,
$next
=
next
||
$active
[
type
]()
,
isCycling
=
this
.
interval
,
direction
=
type
==
'
next
'
?
'
left
'
:
'
right
'
,
fallback
=
type
==
'
next
'
?
'
first
'
:
'
last
'
...
...
@@ -71,8 +92,8 @@
this
.
$element
.
trigger
(
'
slide
'
)
$active
.
removeClass
(
'
active
'
)
$next
.
addClass
(
'
active
'
)
this
.
$element
.
trigger
(
'
slid
'
)
this
.
sliding
=
false
this
.
$element
.
trigger
(
'
slid
'
)
}
else
{
$next
.
addClass
(
type
)
$next
[
0
].
offsetWidth
// force reflow
...
...
@@ -82,8 +103,8 @@
this
.
$element
.
one
(
$
.
support
.
transition
.
end
,
function
()
{
$next
.
removeClass
([
type
,
direction
].
join
(
'
'
)).
addClass
(
'
active
'
)
$active
.
removeClass
([
'
active
'
,
direction
].
join
(
'
'
))
that
.
$element
.
trigger
(
'
slid
'
)
that
.
sliding
=
false
setTimeout
(
function
()
{
that
.
$element
.
trigger
(
'
slid
'
)
},
0
)
})
}
...
...
@@ -104,7 +125,8 @@
,
data
=
$this
.
data
(
'
carousel
'
)
,
options
=
typeof
option
==
'
object
'
&&
option
if
(
!
data
)
$this
.
data
(
'
carousel
'
,
(
data
=
new
Carousel
(
this
,
options
)))
if
(
typeof
option
==
'
string
'
||
(
option
=
options
.
slide
))
data
[
option
]()
if
(
typeof
option
==
'
number
'
)
data
.
to
(
option
)
else
if
(
typeof
option
==
'
string
'
||
(
option
=
options
.
slide
))
data
[
option
]()
else
data
.
cycle
()
})
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment