');
//X movement bigger than Y movement?
if (options.direction === 'horizontal' && Math.abs(touchStartX - touchEndX) > (Math.abs(touchStartY - touchEndY))) {
//is the movement greater than the minimum resistance to scroll?
if (Math.abs(touchStartX - touchEndX) > (container.width() / 100 * options.touchSensitivity)) {
if (touchStartX > touchEndX) {
scrolling('down', scrollable);
} else if (touchEndX > touchStartX) {
scrolling('up', scrollable);
}
}
} else {
if (Math.abs(touchStartY - touchEndY) > (container.height() / 100 * options.touchSensitivity)) {
if (touchStartY > touchEndY) {
scrolling('down', scrollable);
} else if (touchEndY > touchStartY) {
scrolling('up', scrollable);
}
}
}
}
}
}
/**
* recursive function to loop up the parent nodes to check if one of them exists in options.normalScrollElements
* Currently works well for iOS - Android might need some testing
* @param {Element} el target element / jquery selector (in subsequent nodes)
* @param {int} hop current hop compared to options.normalScrollElementTouchThreshold
* @return {boolean} true if there is a match to options.normalScrollElements
*/
function checkParentForNormalScrollElement (el, hop) {
hop = hop || 0;
var parent = $(el).parent();
if (hop < options.normalScrollElementTouchThreshold &&
parent.is(options.normalScrollElements) ) {
return true;
} else if (hop == options.normalScrollElementTouchThreshold) {
return false;
} else {
return checkParentForNormalScrollElement(parent, ++hop);
}
}
/**
* Creates a vertical navigation bar.
*/
function addVerticalNavigation(){
$('body').append('
');
var nav = $('#pp-nav');
nav.css('color', options.navigation.textColor);
nav.addClass(options.navigation.position);
for(var cont = 0; cont < $('.pp-section').length; cont++){
var link = '';
if(options.anchors.length){
link = options.anchors[cont];
}
if(options.navigation.tooltips !== 'undefined'){
var tooltip = options.navigation.tooltips[cont];
if(typeof tooltip === 'undefined'){
tooltip = '';
}
}
nav.find('ul').append('
');
}
nav.find('span').css('border-color', options.navigation.bulletsColor);
}
/**
* Scrolls to the section when clicking the navigation bullet
*/
$(document).on('click touchstart', '#pp-nav a', function(e){
e.preventDefault();
var index = $(this).parent().index();
scrollPage($('.pp-section').eq(index));
});
/**
* Navigation tooltips
*/
$(document).on({
mouseenter: function(){
var tooltip = $(this).data('tooltip');
$('
' + tooltip + '
').hide().appendTo($(this)).fadeIn(200);
},
mouseleave: function(){
$(this).find('.pp-tooltip').fadeOut(200, function() {
$(this).remove();
});
}
}, '#pp-nav li');
/**
* Activating the website navigation dots according to the given slide name.
*/
function activateNavDots(name, sectionIndex){
if(options.navigation){
$('#pp-nav').find('.active').removeClass('active');
if(name){
$('#pp-nav').find('a[href="#' + name + '"]').addClass('active');
}else{
$('#pp-nav').find('li').eq(sectionIndex).find('a').addClass('active');
}
}
}
/**
* Activating the website main menu elements according to the given slide name.
*/
function activateMenuElement(name){
if(options.menu){
$(options.menu).find('.active').removeClass('active');
$(options.menu).find('[data-menuanchor="'+name+'"]').addClass('active');
}
}
/**
* Checks for translate3d support
* @return boolean
* http://stackoverflow.com/questions/5661671/detecting-transform-translate3d-support
*/
function support3d() {
var el = document.createElement('p'),
has3d,
transforms = {
'webkitTransform':'-webkit-transform',
'OTransform':'-o-transform',
'msTransform':'-ms-transform',
'MozTransform':'-moz-transform',
'transform':'transform'
};
// Add it to the body to get the computed style.
document.body.insertBefore(el, null);
for (var t in transforms) {
if (el.style[t] !== undefined) {
el.style[t] = 'translate3d(1px,1px,1px)';
has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]);
}
}
document.body.removeChild(el);
return true;
}
/**
* Gets the translate3d property to apply when using css3:true depending on the `direction` option.
*/
function getTranslate3d(){
if (options.direction !== 'vertical') {
return 'translate3d(-100%, 0px, 0px)';
}
return 'translate3d(0px, -100%, 0px)';
}
};
})(jQuery, document, window);