Ref: http://cssmenumaker.com/blog/solving-the-double-tap-issue-on-ios-devices http://webskillup.com/ety/20150816234007/
<!-- Smooth Scroll & Disabling Double-tap -->
<script type="text/javascript">
jQuery(document).ready(function($){
$('a[href*=#]:not([href=#])').on('click touchend', function(e) {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 700);
return false;
}
}
});
});
</script>
<!-- Note: -->
<!-- 上のコードは、以下の二つのスクリプトを組み合わせたもの、以下の二つは単独だと働くが、両方使うと、Smooth Scroll が働かない。 -->
<!-- Smooth Scroll Only -->
<script type="text/javascript">
jQuery(document).ready(function($){
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 700);
return false;
}
}
});
});
</script>
<!-- Disable Double-tap Issue on iOS Only -->
<script type="text/javascript">
$(document).ready(function() {
$('a').on('click touchend', function(e) {
var el = $(this);
var link = el.attr('href');
window.location = link;
});
});
</script>