Skip to content

Commit

Permalink
Merge pull request nolimits4web#2939 from kireerik/Slideable-Navigati…
Browse files Browse the repository at this point in the history
…on-Drawer-Demo-improvement

Improve the Slideable Navigation Drawer Demo
  • Loading branch information
nolimits4web authored Jan 29, 2019
2 parents c6f9269 + 202a828 commit cf92687
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions demos/430-slideable-menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,29 +160,30 @@
<!-- Initialize Swiper -->
<script>
var menuButton = document.querySelector('.menu-button');
var openMenu = function () {
swiper.slidePrev();
};
var swiper = new Swiper('.swiper-container', {
slidesPerView: 'auto',
initialSlide: 1,
resistanceRatio: 0,
slideToClickedSlide: true,
on: {
init: function () {
var slider = this;
menuButton.addEventListener('click', function () {
if (slider.activeIndex === 0) {
slider.slideNext();
} else {
slider.slidePrev();
}
}, true);
},
slideChange: function () {
slideChangeTransitionStart: function () {
var slider = this;
if (slider.activeIndex === 0) {
menuButton.classList.add('cross');
// required because of slideToClickedSlide
menuButton.removeEventListener('click', openMenu, true);
} else {
menuButton.classList.remove('cross');
}
}
, slideChangeTransitionEnd: function () {
var slider = this;
if (slider.activeIndex === 1) {
menuButton.addEventListener('click', openMenu, true);
}
},
}
});
Expand Down

0 comments on commit cf92687

Please sign in to comment.