Fix button and add hash to URL
This commit is contained in:
parent
4ea916f8b8
commit
74bdc30f2b
|
@ -14,7 +14,7 @@
|
||||||
{{ with .Params.Name }}
|
{{ with .Params.Name }}
|
||||||
{{ $button_title = . }}
|
{{ $button_title = . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<a class='btn site-menu' data-title-anchor='{{ anchorize $button_title }}'>{{ $button_title }}</a>
|
<a class='btn site-menu' data-title-anchor='{{ anchorize .Title }}'>{{ $button_title }}</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<i id='header-arrow' class="fa fa-angle-down"></i>
|
<i id='header-arrow' class="fa fa-angle-down"></i>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -13,12 +13,15 @@ var $sitehead = $("#site-head");
|
||||||
/* Globals jQuery, document */
|
/* Globals jQuery, document */
|
||||||
(function ($) {
|
(function ($) {
|
||||||
"use strict";
|
"use strict";
|
||||||
function srcTo(el) {
|
function srcTo(el, dur = 1000) {
|
||||||
$("html, body").animate(
|
$("html, body").animate(
|
||||||
{
|
{
|
||||||
scrollTop: el.offset().top,
|
scrollTop: el.offset().top,
|
||||||
},
|
},
|
||||||
1000
|
dur,
|
||||||
|
function() {
|
||||||
|
window.location.hash = el.attr("id");
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
function srcToAnchorWithTitle(str) {
|
function srcToAnchorWithTitle(str) {
|
||||||
|
@ -51,19 +54,14 @@ var $sitehead = $("#site-head");
|
||||||
$(".post-title").each(function () {
|
$(".post-title").each(function () {
|
||||||
var t = $(this).data("fnav-title");
|
var t = $(this).data("fnav-title");
|
||||||
var index = $(this).parents(".post-holder").index();
|
var index = $(this).parents(".post-holder").index();
|
||||||
|
var postId = $(this).closest("article.post").attr('id');
|
||||||
$fnav.append(
|
$fnav.append(
|
||||||
"<a class='fn-item' item_index='" + index + "'>" + t + "</a>"
|
"<a class='fn-item' item_index='" + index + "' data-post-id='" + postId + "'>" + t + "</a>"
|
||||||
);
|
);
|
||||||
$(".fn-item").click(function () {
|
$(".fn-item").click(function () {
|
||||||
var i = $(this).attr("item_index");
|
var postId = $(this).data("post-id");
|
||||||
var s = $(".post[item_index='" + i + "']");
|
var s = $("#" + postId);
|
||||||
|
srcTo(s, 400);
|
||||||
$("html, body").animate(
|
|
||||||
{
|
|
||||||
scrollTop: s.offset().top,
|
|
||||||
},
|
|
||||||
400
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue