Skip to content

Commit

Permalink
Fix navar-collapse-fixed-top
Browse files Browse the repository at this point in the history
Fixed: #110
  • Loading branch information
joomlart committed Jul 4, 2013
1 parent 78c4d0e commit 5af8c48
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 15 deletions.
30 changes: 19 additions & 11 deletions source/plg_system_t3/base/js/off-canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
$nav = null,
$fixeditems = null;

if (!$btn.length) return;
if (!$btn.length){
return;
}

//mark that we have off-canvas menu
$(document.documentElement).addClass('off-canvas-ready');

$nav = $('<div class="t3-mainnav" />').appendTo($('<div id="off-canvas-nav"></div>').appendTo(document.body));
$($btn.data('target')).clone().appendTo($nav);
Expand All @@ -37,16 +42,16 @@
return false;
});

posNav = function () {
var posNav = function () {
var t = $(window).scrollTop();
if (t < $nav.position().top) $nav.css('top', t);
};
},

bdHideNav = function (e) {
e.preventDefault();
hideNav();
return false;
};
},

showNav = function () {
$('html').addClass ('off-canvas');
Expand All @@ -71,9 +76,9 @@
setTimeout (function(){
wpfix(2);
}, 1000);
};
},

hideNav = function () {
hideNav = function () {
$(window).unbind('scroll touchmove', posNav);
$('#off-canvas-nav').unbind ('click');
$('#off-canvas-nav a').unbind ('click', hideNav);
Expand All @@ -85,25 +90,28 @@
setTimeout (function(){
$('html').removeClass ('off-canvas');
}, 600);
};
},

wpfix = function (step) {
// check if need fixed
if ($fixeditems == -1) return ;// no need to fix
if ($fixeditems == -1){
return;// no need to fix
}

if (!$fixeditems) {
$fixeditems = $('body').children().filter(function(){ return $(this).css('position') === 'fixed' });
if (!$fixeditems.length) {
$fixeditems = -1;
return ;
return;
}
}

if (step==1) {
$fixeditems.css({'position': 'absolute', 'top': $(window).scrollTop()+'px'});
$fixeditems.css({'position': 'absolute', 'top': $(window).scrollTop() + 'px'});
} else {
$fixeditems.css({'position': '', 'top': ''});
}
}
};
}
})

Expand Down
37 changes: 37 additions & 0 deletions source/plg_system_t3/base/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,41 @@
});
}
});

//fix animation for navbar-collapse-fixed-top||bottom
$(window).load(function(){
if ($.support.transition) {
if(!$(document.documentElement).hasClass('off-canvas-ready') &&
($('.navbar-collapse-fixed-top').length ||
$('.navbar-collapse-fixed-bottom').length)){

var btn = $('.btn-navbar');
if (!btn.length){
return;
}

if(btn.data('target')){
var nav = $(btn.data('target'));
if(!nav.length){
return;
}

var fixedtop = nav.closest('.navbar-collapse-fixed-top').length;

btn.on('click', function(){
nav
.addClass('animate')
.css('max-height', fixedtop ?
((window.innerHeight || $(window).height()) - (parseFloat(nav.css('top')) || 0)) :
(parseFloat(nav.css('bottom')) || 0));
});
nav.on('shown hidden', function(){
nav.removeClass('animate');
});
}
}
}
});


}(jQuery);
3 changes: 2 additions & 1 deletion source/plg_system_t3/base/less/t3-responsive.less
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
overflow-y: auto;
top: @navbarHeight;
bottom: 0;
-webkit-overflow-scrolling: touch;
> * {
padding-bottom: 50px;
-webkit-transform: translateZ(0);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion source/tpl_t3_blank/less/navigation-responsive.less
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@

// Full width when fixed
// ---------------------
&.navbar-collapse-fixed-top {
&.navbar-collapse-fixed-top,
&.navbar-collapse-fixed-bottom {
margin-left: 0;
margin-right: 0;
}
Expand Down
4 changes: 2 additions & 2 deletions source/tpl_t3_blank/tpls/blocks/mainnav.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
<i class="icon-reorder"></i>
</button>

<div class="nav-collapse collapse<?php echo $this->getParam('navigation_collapse_showsub', 1) ? ' always-show' : '' ?>">
<div class="nav-collapse collapse<?php echo $this->getParam('navigation_collapse_showsub', 1) ? ' always-show' : '' ?>">
<?php if ($this->getParam('navigation_type') == 'megamenu') : ?>
<?php $this->megamenu($this->getParam('mm_type', 'mainmenu')) ?>
<?php else : ?>
<jdoc:include type="modules" name="<?php $this->_p('mainnav') ?>" style="raw" />
<?php endif ?>
</div>
</div>
</div>
</div>
</nav>
Expand Down

2 comments on commit 5af8c48

@pepperstreet
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still got the same issues described in #110
#110

@joomlart
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed 094bf1f

Please sign in to comment.