Skip to content

Commit

Permalink
opti: toc
Browse files Browse the repository at this point in the history
  • Loading branch information
kitian616 committed Apr 4, 2018
1 parent 218bda9 commit 7aa6b2b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 7 deletions.
19 changes: 12 additions & 7 deletions _includes/scripts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,35 @@
}
lastScrollTop = scrollTop;
}
setTimeout(function() {
}, 100);
asideSticky() && (init(), setAside());
setTimeout(function() {
init();
$window.on('load', function() {
init();
});
}, 2000);
$window.on('scroll', function() {
asideSticky() && setAside();
});
$window.on('resize', window.throttle(function() {
setTocClass();
asideSticky() && (init(), setAside(true));
}, 100));
setTimeout(init, 4000);
}
function toc() {
var $tocUl = $('<ul></ul>'), $tocLi, $headings = $articleContent.find('{{ _toc_selectors }}'), headingsTop = [],
var $tocUl = $('<ul></ul>'), $tocLi, $headings = $articleContent.find('{{ _toc_selectors }}'), headingsTop = null,
scrolling, activeLast, activeCur, rendered = false;
function init() {
headingsTop = [];
$headings.each(function() {
headingsTop.push(Math.floor($(this).offset().top));
});
}
function setActiveHeading(element, disabled) {
var scrollTop = $window.scrollTop(), i;
if (disabled || headingsTop.length < 1) { return; }
if (disabled || !headingsTop || headingsTop.length < 1) { return; }
if (element) {
activeCur = element;
} else {
Expand Down Expand Up @@ -112,10 +120,7 @@
rendered = true;
}
asideSticky() && (render(), $window.on('load', function() {
setTimeout(function() {
init();
setActiveHeading(null, scrolling);
}, 1000);
init(); setActiveHeading(null, scrolling);
}));
$window.on('resize', window.throttle(function() {
if (asideSticky()) {
Expand Down
44 changes: 44 additions & 0 deletions test/_posts/2015-01-03-article-with-lot-images.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
layout: post
title: Test - Article With A Lot Of images
key: 20150103
tags: Test English
---

## TeXt Theme

![TeXt Theme](https://raw.githubusercontent.com/kitian616/jekyll-TeXt-theme/master/screenshots/TeXt-home.png)

## TeXt Theme Details

![TeXt Theme Details](https://raw.githubusercontent.com/kitian616/jekyll-TeXt-theme/master/screenshots/TeXt-details.png)

## Color Theme: Default

![default](https://raw.githubusercontent.com/kitian616/jekyll-TeXt-theme/master/screenshots/colors_default.png)

## Color Theme: Dark

![dark](https://raw.githubusercontent.com/kitian616/jekyll-TeXt-theme/master/screenshots/colors_dark.png)

## Color Theme: Forest

![forest](https://raw.githubusercontent.com/kitian616/jekyll-TeXt-theme/master/screenshots/colors_forest.png)

## Color Theme: Ocean

![ocean](https://raw.githubusercontent.com/kitian616/jekyll-TeXt-theme/master/screenshots/colors_ocean.png)

## Color Theme: Chocolate

![chocolate](https://raw.githubusercontent.com/kitian616/jekyll-TeXt-theme/master/screenshots/colors_chocolate.png)

## Color Theme: Orange

![orange](https://raw.githubusercontent.com/kitian616/jekyll-TeXt-theme/master/screenshots/colors_orange.png)

<script>
window.onload=function(){
console.log('load');
}
</script>

0 comments on commit 7aa6b2b

Please sign in to comment.