Skip to content

Commit

Permalink
chore: 暂存代码
Browse files Browse the repository at this point in the history
  • Loading branch information
yaohaixiao committed Apr 8, 2024
1 parent 307ee81 commit 05da7a9
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 33 deletions.
2 changes: 1 addition & 1 deletion docs/js/navigator.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/js/navigator.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/js/outline.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/js/outline.min.js.map

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,17 +379,18 @@ class Navigator extends Base {

if (animationCurrent) {
this.positionPlaceholder(this.active)

later(() => {
if (!inBounding(this.$active, this.$parentElement)) {
placeholderOffsetTop = this._getPlaceholderOffset(this.active)
scrollTo(this.$main, placeholderOffsetTop)
}
})
} else {
addClass(this.$active, HIGHLIGHT)
}

later(() => {
if (!inBounding(this.$active, this.$main)) {
placeholderOffsetTop = this._getPlaceholderOffset(this.active)
console.log('placeholderOffsetTop', placeholderOffsetTop)
scrollTo(this.$main, placeholderOffsetTop)
}
})

return this
}

Expand Down
2 changes: 1 addition & 1 deletion navigator.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion navigator.min.js.map

Large diffs are not rendered by default.

39 changes: 21 additions & 18 deletions outline.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,24 @@ class Outline extends Base {
return this
}

_updateToolbar({ top, min, max }) {
const toolbar = this.toolbar
const current = Math.ceil(top)

if (current <= min) {
toolbar.hide('up')
toolbar.show('down')
} else if (current >= max) {
toolbar.hide('down')
toolbar.show('up')
} else if (current > min && current < max) {
toolbar.show('up')
toolbar.show('down')
}

return this
}

toTop() {
const afterScroll = this.attr('afterScroll')
const toolbar = this.toolbar
Expand All @@ -372,6 +390,7 @@ class Outline extends Base {
if (count > 0) {
navigator.highlight(0)
navigator.playing = false
scrollTo(navigator.$main, 0)
}

if (isFunction(afterScroll)) {
Expand All @@ -387,24 +406,6 @@ class Outline extends Base {
return this
}

_updateToolbar({ top, min, max }) {
const toolbar = this.toolbar
const current = Math.ceil(top)

if (current <= min) {
toolbar.hide('up')
toolbar.show('down')
} else if (current >= max) {
toolbar.hide('down')
toolbar.show('up')
} else if (current > min && current < max) {
toolbar.show('up')
toolbar.show('down')
}

return this
}

toBottom() {
const afterScroll = this.attr('afterScroll')
const $scrollElement = this.$scrollElement
Expand All @@ -415,11 +416,13 @@ class Outline extends Base {
$scrollElement.scrollHeight - $scrollElement.clientHeight
)
const afterDown = () => {
const $main = navigator.$main
toolbar.hide('down')
toolbar.show('up')

if (count > 0) {
navigator.highlight(count - 1)
scrollTo($main, $main.scrollHeight)
navigator.playing = false
}

Expand Down
2 changes: 1 addition & 1 deletion outline.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion outline.min.js.map

Large diffs are not rendered by default.

0 comments on commit 05da7a9

Please sign in to comment.