Skip to content

Commit

Permalink
Merge pull request #29 from jasongerbes/add-track-option
Browse files Browse the repository at this point in the history
Add addTrack option
  • Loading branch information
NickPiscitelli authored Dec 27, 2018
2 parents 71d0095 + 365b65c commit 9a644cb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/assets/js/glider.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,13 @@ <h2>Settings</h2>
<span class="type default">Default:</span> true<br>
Whether or not Glider.js events should bubble (useful for binding events to all carousels)
</li>

<li>
<span class="setting-name">addTrack</span><br>
<span class="type">Type:</span> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a><br>
<span class="type default">Default:</span> true<br>
Whether or not Glider.js should wrap it's children with a 'glider-track' &lt;div&gt;.
<span class="aside">NOTE: If false, Glider.js will assume that the 'glider-track' element has been added manually. All slides must be children of the track element.</span>
</li>

</ul>
</section>
Expand Down
21 changes: 14 additions & 7 deletions glider.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
// easeInQuad
easing: function (x, t, b, c, d) {
return c * (t /= d) * t + b
}
},
addTrack: true
},
settings
)
Expand All @@ -63,14 +64,20 @@
// extend breakpoint settings
_._opt = _.opt

// create track and wrap slides
_.track = document.createElement('div')
_.track.className = 'glider-track'
_.ele.appendChild(_.track)
while (_.ele.children.length !== 1) {
_.track.appendChild(_.ele.children[0])
if (_.opt.addTrack) {
// create track and wrap slides
_.track = document.createElement('div')
_.ele.appendChild(_.track)
while (_.ele.children.length !== 1) {
_.track.appendChild(_.ele.children[0])
}
} else {
// first and only child is the track
_.track = _.ele.children[0]
}

_.track.classList.add('glider-track')

// start glider
_.init()

Expand Down
Loading

0 comments on commit 9a644cb

Please sign in to comment.