Skip to content

Commit

Permalink
Fix click on anchor in offvanvas menu. Fix #433
Browse files Browse the repository at this point in the history
  • Loading branch information
joomlart committed Apr 6, 2016
1 parent a52b4d7 commit a8e188f
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions source/plg_system_t3/base-bs3/js/off-canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jQuery (document).ready(function($){
$wrapper.addClass ('off-canvas-open');
$inner.on ('click', oc_hide);
$close.on ('click', oc_hide);
$offcanvas.on ('click', stopBubble);
$offcanvas.on ('click', handleClick);

// fix for old ie
if ($.browser.msie && $.browser.version < 10) {
Expand All @@ -147,7 +147,7 @@ jQuery (document).ready(function($){
//remove events
$inner.off ('click', oc_hide);
$close.off ('click', oc_hide);
$offcanvas.off ('click', stopBubble);
$offcanvas.off ('click', handleClick);

//delay for click action
setTimeout(function(){
Expand Down Expand Up @@ -185,9 +185,27 @@ jQuery (document).ready(function($){

};

var handleClick = function (e) {
if (e.target.tagName == 'A') {
oc_hide();
// handle the anchor link
var arr1 = e.target.href.split('#'),
arr2 = location.href.split('#');
if (arr1[0] == arr2[0] && arr1.length > 1) {
setTimeout(function(){
var anchor = $("a[name='"+ arr1[1] +"']");
if (!anchor.length) anchor = $('#' + arr1[1]);
$('html,body').animate({scrollTop: anchor.offset().top},'slow');
}, 500);
}
return ;
}
stopBubble(e);
return true;
}

var stopBubble = function (e) {
e.stopPropagation();
return true;
}

// preload fixed items
Expand Down

0 comments on commit a8e188f

Please sign in to comment.