-
Notifications
You must be signed in to change notification settings - Fork 619
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
62 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,68 @@ | ||
'use strict'; | ||
(function () { | ||
'use strict'; | ||
|
||
// load dependencies | ||
var animationControl = require('./animation-control.js'); | ||
// load dependencies | ||
var animationControl = require('./animation-control.js'); | ||
|
||
|
||
$(document).ready(function () { | ||
var bgMusic = $('audio').get(0); | ||
var $btnMusic = $('.btn-music'); | ||
var $btnSwipe = $('.btn-swipe'); | ||
$(document).ready(function () { | ||
var bgMusic = $('audio').get(0); | ||
var $btnMusic = $('.btn-music'); | ||
var $btnSwipe = $('.btn-swipe'); | ||
|
||
// background music control | ||
$btnMusic.click(function () { | ||
if (bgMusic.paused) { | ||
bgMusic.play(); | ||
$(this).removeClass('paused'); | ||
} else { | ||
bgMusic.pause(); | ||
$(this).addClass('paused'); | ||
} | ||
}); | ||
|
||
// init Swiper | ||
new Swiper('.swiper-container', { | ||
mousewheelControl: true, | ||
effect: 'coverflow', // slide, fade, coverflow or flip | ||
speed: 400, | ||
direction: 'vertical', | ||
fade: { | ||
crossFade: false | ||
}, | ||
coverflow: { | ||
rotate: 100, | ||
stretch: 0, | ||
depth: 300, | ||
modifier: 1, | ||
slideShadows: false // do disable shadows for better performance | ||
}, | ||
flip: { | ||
limitRotation: true, | ||
slideShadows: false // do disable shadows for better performance | ||
}, | ||
onInit: function (swiper) { | ||
animationControl.initAnimationItems(); // get items ready for animations | ||
animationControl.playAnimation(swiper); // play animations of the first slide | ||
}, | ||
onTransitionStart: function (swiper) { // on the last slide, hide .btn-swipe | ||
if (swiper.activeIndex === swiper.slides.length - 1) { | ||
$btnSwipe.hide(); | ||
// background music control | ||
$btnMusic.click(function () { | ||
if (bgMusic.paused) { | ||
bgMusic.play(); | ||
$(this).removeClass('paused'); | ||
} else { | ||
$btnSwipe.show(); | ||
bgMusic.pause(); | ||
$(this).addClass('paused'); | ||
} | ||
}, | ||
onTransitionEnd: function (swiper) { // play animations of the current slide | ||
animationControl.playAnimation(swiper); | ||
}, | ||
onTouchStart: function (swiper, event) { // mobile devices don't allow audios to play automatically, it has to be triggered by a user event(click / touch). | ||
if (!$btnMusic.hasClass('paused') && bgMusic.paused) { | ||
bgMusic.play(); | ||
}); | ||
|
||
// init Swiper | ||
new Swiper('.swiper-container', { | ||
mousewheelControl: true, | ||
effect: 'coverflow', // slide, fade, coverflow or flip | ||
speed: 400, | ||
direction: 'vertical', | ||
fade: { | ||
crossFade: false | ||
}, | ||
coverflow: { | ||
rotate: 100, | ||
stretch: 0, | ||
depth: 300, | ||
modifier: 1, | ||
slideShadows: false // do disable shadows for better performance | ||
}, | ||
flip: { | ||
limitRotation: true, | ||
slideShadows: false // do disable shadows for better performance | ||
}, | ||
onInit: function (swiper) { | ||
animationControl.initAnimationItems(); // get items ready for animations | ||
animationControl.playAnimation(swiper); // play animations of the first slide | ||
}, | ||
onTransitionStart: function (swiper) { // on the last slide, hide .btn-swipe | ||
if (swiper.activeIndex === swiper.slides.length - 1) { | ||
$btnSwipe.hide(); | ||
} else { | ||
$btnSwipe.show(); | ||
} | ||
}, | ||
onTransitionEnd: function (swiper) { // play animations of the current slide | ||
animationControl.playAnimation(swiper); | ||
}, | ||
onTouchStart: function (swiper, event) { // mobile devices don't allow audios to play automatically, it has to be triggered by a user event(click / touch). | ||
if (!$btnMusic.hasClass('paused') && bgMusic.paused) { | ||
bgMusic.play(); | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
// hide loading animation since everything is ready | ||
$('.loading-overlay').slideUp(); | ||
}); | ||
// hide loading animation since everything is ready | ||
$('.loading-overlay').slideUp(); | ||
}); | ||
})(); |