Skip to content

Commit e28c1ef

Browse files
committed
- Solved bug with tooltips
- Improved performance and magnification
1 parent 863f3b8 commit e28c1ef

File tree

2 files changed

+46
-47
lines changed

2 files changed

+46
-47
lines changed

jquery.pagepiling.js

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* ===========================================================
2-
* pagepiling.js 1.2
2+
* pagepiling.js 1.3
33
*
44
* https://github.com/alvarotrigo/pagePiling.js
55
* MIT licensed
@@ -8,8 +8,9 @@
88
*
99
* ========================================================== */
1010

11-
(function ($) {
11+
(function ($, document, window, undefined) {
1212
$.fn.pagepiling = function (custom) {
13+
var PP = $.fn.pagepiling;
1314
var container = $(this);
1415
var lastScrolledDestiny;
1516
var lastAnimation = 0;
@@ -37,7 +38,7 @@
3738
textColor: '#000',
3839
bulletsColor: '#000',
3940
position: 'right',
40-
tooltips: null
41+
tooltips: []
4142
},
4243
normalScrollElements: null,
4344
normalScrollElementTouchThreshold: 5,
@@ -59,14 +60,14 @@
5960
/**
6061
* Defines the scrolling speed
6162
*/
62-
$.fn.pagepiling.setScrollingSpeed = function(value){
63+
PP.setScrollingSpeed = function(value){
6364
options.scrollingSpeed = value;
6465
};
6566

6667
/**
6768
* Adds or remove the possiblity of scrolling through sections by using the mouse wheel or the trackpad.
6869
*/
69-
$.fn.pagepiling.setMouseWheelScrolling = function (value){
70+
PP.setMouseWheelScrolling = function (value){
7071
if(value){
7172
addMouseWheelHandler();
7273
}else{
@@ -77,27 +78,27 @@
7778
/**
7879
* Adds or remove the possiblity of scrolling through sections by using the mouse wheel/trackpad or touch gestures.
7980
*/
80-
$.fn.pagepiling.setAllowScrolling = function (value){
81+
PP.setAllowScrolling = function (value){
8182
if(value){
82-
$.fn.pagepiling.setMouseWheelScrolling(true);
83+
PP.setMouseWheelScrolling(true);
8384
addTouchHandler();
8485
}else{
85-
$.fn.pagepiling.setMouseWheelScrolling(false);
86+
PP.setMouseWheelScrolling(false);
8687
removeTouchHandler();
8788
}
8889
};
8990

9091
/**
9192
* Adds or remove the possiblity of scrolling through sections by using the keyboard arrow keys
9293
*/
93-
$.fn.pagepiling.setKeyboardScrolling = function (value){
94+
PP.setKeyboardScrolling = function (value){
9495
options.keyboardScrolling = value;
9596
};
9697

9798
/**
9899
* Moves sectio up
99100
*/
100-
$.fn.pagepiling.moveSectionUp = function () {
101+
PP.moveSectionUp = function () {
101102
var prev = $('.pp-section.active').prev('.pp-section');
102103

103104
//looping to the bottom if there's no more sections above
@@ -113,7 +114,7 @@
113114
/**
114115
* Moves sectio down
115116
*/
116-
$.fn.pagepiling.moveSectionDown = function () {
117+
PP.moveSectionDown = function () {
117118
var next = $('.pp-section.active').next('.pp-section');
118119

119120
//looping to the top if there's no more sections below
@@ -129,7 +130,7 @@
129130
/**
130131
* Moves the site to the given anchor or index
131132
*/
132-
$.fn.pagepiling.moveTo = function (section){
133+
PP.moveTo = function (section){
133134
var destiny = '';
134135

135136
if(isNaN(section)){
@@ -161,7 +162,7 @@
161162
});
162163

163164
//init
164-
$.fn.pagepiling.setAllowScrolling(true);
165+
PP.setAllowScrolling(true);
165166

166167
//creating the navigation dots
167168
if (!$.isEmptyObject(options.navigation) ) {
@@ -508,33 +509,33 @@
508509
//up
509510
case 38:
510511
case 33:
511-
$.fn.pagepiling.moveSectionUp();
512+
PP.moveSectionUp();
512513
break;
513514

514515
//down
515516
case 40:
516517
case 34:
517-
$.fn.pagepiling.moveSectionDown();
518+
PP.moveSectionDown();
518519
break;
519520

520521
//Home
521522
case 36:
522-
$.fn.pagepiling.moveTo(1);
523+
PP.moveTo(1);
523524
break;
524525

525526
//End
526527
case 35:
527-
$.fn.pagepiling.moveTo($('.pp-section').length);
528+
PP.moveTo($('.pp-section').length);
528529
break;
529530

530531
//left
531532
case 37:
532-
$.fn.pagepiling.moveSectionUp();
533+
PP.moveSectionUp();
533534
break;
534535

535536
//right
536537
case 39:
537-
$.fn.pagepiling.moveSectionDown();
538+
PP.moveSectionDown();
538539
break;
539540

540541
default:
@@ -549,11 +550,11 @@
549550
*/
550551
if(options.normalScrollElements){
551552
$(document).on('mouseenter', options.normalScrollElements, function () {
552-
$.fn.pagepiling.setMouseWheelScrolling(false);
553+
PP.setMouseWheelScrolling(false);
553554
});
554555

555556
$(document).on('mouseleave', options.normalScrollElements, function(){
556-
$.fn.pagepiling.setMouseWheelScrolling(true);
557+
PP.setMouseWheelScrolling(true);
557558
});
558559
}
559560

@@ -594,10 +595,10 @@
594595
function scrolling(type, scrollable){
595596
if(type == 'down'){
596597
var check = 'bottom';
597-
var scrollSection = $.fn.pagepiling.moveSectionDown;
598+
var scrollSection = PP.moveSectionDown;
598599
}else{
599600
var check = 'top';
600-
var scrollSection = $.fn.pagepiling.moveSectionUp;
601+
var scrollSection = PP.moveSectionUp;
601602
}
602603

603604
if(scrollable.length > 0 ){
@@ -811,7 +812,7 @@
811812
if(options.anchors.length){
812813
link = options.anchors[cont];
813814
}
814-
if(typeof options.navigation.tooltips !== 'undefined'){
815+
if(options.navigation.tooltips !== 'undefined'){
815816
var tooltip = options.navigation.tooltips[cont];
816817
if(typeof tooltip === 'undefined'){
817818
tooltip = '';
@@ -916,4 +917,4 @@
916917
}
917918

918919
};
919-
})(jQuery);
920+
}(jQuery, document, window));

0 commit comments

Comments
 (0)