Skip to content

Commit

Permalink
Bug: Site overview tab can't be activated when disable motion. #212
Browse files Browse the repository at this point in the history
  • Loading branch information
iissnan committed Jul 27, 2015
1 parent 88630ca commit a228192
Showing 1 changed file with 58 additions and 37 deletions.
95 changes: 58 additions & 37 deletions layout/_scripts/pages/post-details.swig
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
element.on('mousewheel DOMMouseScroll', function (event) {
var oe = event.originalEvent;
var delta = oe.wheelDelta || -oe.detail;
var self = this;

this.scrollTop += ( delta < 0 ? 1 : -1 ) * 30;
event.preventDefault();
Expand All @@ -79,57 +78,79 @@
}

function tocOverflowIndicator (indicator, action) {
$(indicator).velocity('stop').velocity({
opacity: action === 'show' ? 0.4 : 0
}, { duration: 100 });
var $indicator = $(indicator);
var opacity = action === 'show' ? 0.4 : 0;
$indicator.velocity ?
$indicator.velocity('stop').velocity({
opacity: opacity
}, { duration: 100 }) :
$indicator.stop().animate({
opacity: opacity
}, 100);
}

});
</script>

{% if theme.use_motion %}
<script type="text/javascript" id="sidebar.nav">
$(document).ready(function () {
var html = $('html');

$('.sidebar-nav li').on('click', function () {
var item = $(this);
var activeTabClassName = 'sidebar-nav-active';
var activePanelClassName = 'sidebar-panel-active';
if (item.hasClass(activeTabClassName)) {
return;
}
<script type="text/javascript" id="sidebar.nav">
$(document).ready(function () {
var html = $('html');
var TAB_ANIMATE_DURATION = 200;
var hasVelocity = $.isFunction(html.velocity);

$('.sidebar-nav li').on('click', function () {
var item = $(this);
var activeTabClassName = 'sidebar-nav-active';
var activePanelClassName = 'sidebar-panel-active';
if (item.hasClass(activeTabClassName)) {
return;
}

var currentTarget = $('.' + activePanelClassName);
var target = $('.' + item.data('target'));
var currentTarget = $('.' + activePanelClassName);
var target = $('.' + item.data('target'));

currentTarget.velocity('transition.slideUpOut', 200, function () {
hasVelocity ?
currentTarget.velocity('transition.slideUpOut', TAB_ANIMATE_DURATION, function () {
target
.velocity('stop')
.velocity('transition.slideDownIn', 200)
.velocity('transition.slideDownIn', TAB_ANIMATE_DURATION)
.addClass(activePanelClassName);
}) :
currentTarget.animate({ opacity: 0 }, TAB_ANIMATE_DURATION, function () {
currentTarget.hide();
target
.stop()
.css({'opacity': 0, 'display': 'block'})
.animate({ opacity: 1 }, TAB_ANIMATE_DURATION, function () {
currentTarget.removeClass(activePanelClassName);
target.addClass(activePanelClassName);
});
});

item.siblings().removeClass(activeTabClassName);
item.addClass(activeTabClassName);
});
item.siblings().removeClass(activeTabClassName);
item.addClass(activeTabClassName);
});

$('.post-toc a').on('click', function (e) {
e.preventDefault();
var offset = $(escapeSelector(this.getAttribute('href'))).offset().top;
$('.post-toc a').on('click', function (e) {
e.preventDefault();
var targetSelector = escapeSelector(this.getAttribute('href'));
var offset = $(targetSelector).offset().top;
hasVelocity ?
html.velocity('stop').velocity('scroll', {
offset: offset + 'px',
mobileHA: false
});
});
}) :
$('html, body').stop().animate({
scrollTop: offset
}, 500);
});

// Expand sidebar on post detail page by default, when post has a toc.
var $tocContent = $('.post-toc-content');
if (isDesktop() && CONFIG.sidebar === 'post') {
if ($tocContent.length > 0 && $tocContent.html().trim().length > 0) {
displaySidebar();
}
// Expand sidebar on post detail page by default, when post has a toc.
var $tocContent = $('.post-toc-content');
if (isDesktop() && CONFIG.sidebar === 'post') {
if ($tocContent.length > 0 && $tocContent.html().trim().length > 0) {
displaySidebar();
}
});
</script>
{% endif %}
}
});
</script>

0 comments on commit a228192

Please sign in to comment.