1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-16 02:24:19 +02:00

rewritten scrollspy without jquery

This commit is contained in:
Alessandro Chitolina
2017-09-25 09:09:01 +02:00
committed by XhmikosR
parent 9744886519
commit 0263d1742c
5 changed files with 117 additions and 49 deletions

View File

@@ -80,7 +80,7 @@ $(function () {
.show()
.find('#scrollspy-example')
.bootstrapScrollspy({
target: '#ss-target'
target: 'ss-target'
})
$scrollspy.one('scroll', function () {
@@ -127,7 +127,7 @@ $(function () {
.show()
.find('#scrollspy-example')
.bootstrapScrollspy({
target: document.getElementById('#ss-target')
target: document.getElementById('ss-target')
})
$scrollspy.one('scroll', function () {
@@ -557,7 +557,7 @@ $(function () {
$scrollspy
.bootstrapScrollspy({
target: '#navigation',
offset: $scrollspy.position().top
offset: $scrollspy[0].offsetTop
})
.one('scroll', function () {
assert.strictEqual($('.active').length, 1, '"active" class on only one element present')
@@ -663,11 +663,11 @@ $(function () {
method: 'offset'
})
} else if (type === 'data') {
$(window).trigger('load')
EventHandler.trigger(window, 'load')
}
var $target = $('#div-' + type + 'm-2')
var scrollspy = $content.data('bs.scrollspy')
var scrollspy = Data.getData($content[0], 'bs.scrollspy')
assert.ok(scrollspy._offsets[1] === $target.offset().top, 'offset method with ' + type + ' option')
assert.ok(scrollspy._offsets[1] !== $target.position().top, 'position method with ' + type + ' option')
@@ -710,11 +710,11 @@ $(function () {
method: 'position'
})
} else if (type === 'data') {
$(window).trigger('load')
EventHandler.trigger(window, 'load')
}
var $target = $('#div-' + type + 'm-2')
var scrollspy = $content.data('bs.scrollspy')
var scrollspy = Data.getData($content[0], 'bs.scrollspy')
assert.ok(scrollspy._offsets[1] !== $target.offset().top, 'offset method with ' + type + ' option')
assert.ok(scrollspy._offsets[1] === $target.position().top, 'position method with ' + type + ' option')

View File

@@ -88,7 +88,10 @@
<script src="../../../node_modules/jquery/dist/jquery.slim.min.js"></script>
<script src="../../../site/docs/4.2/assets/js/vendor/popper.min.js"></script>
<script src="../../dist/dom/data.js"></script>
<script src="../../dist/dom/eventHandler.js"></script>
<script src="../../dist/dom/manipulator.js"></script>
<script src="../../dist/dom/selectorEngine.js"></script>
<script src="../../dist/util.js"></script>
<script src="../../dist/scrollspy.js"></script>
<script src="../../dist/dropdown.js"></script>