Skip to content

Commit adcae39

Browse files
committed
- Solved bug with IE 11 for Windows Phone
- Added `easeInQuart` effect inside the plugin - Added new feature: a class is added to the body on section change
1 parent f8258f1 commit adcae39

File tree

3 files changed

+51
-33
lines changed

3 files changed

+51
-33
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pagePiling.js",
3-
"version": "0.0.9",
3+
"version": "1.0",
44
"homepage": "https://github.com/alvarotrigo/pagePiling.js",
55
"authors": [
66
"Alvaro Trigo https://github.com/alvarotrigo"

jquery.pagepiling.js

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* ===========================================================
2-
* pagepiling.js 0.0.9 (Beta)
2+
* pagepiling.js 1.0
33
*
44
* https://github.com/alvarotrigo/pagePiling.js
55
* MIT licensed
@@ -13,7 +13,7 @@
1313
var container = $(this);
1414
var lastScrolledDestiny;
1515
var lastAnimation = 0;
16-
var isTouch = (('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0));
16+
var isTouch = (('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0) || (navigator.maxTouchPoints));
1717
var touchStartY = touchStartX = touchEndY = touchEndX = 0;
1818

1919
//Defines the delay to take place before being able to scroll to the next section
@@ -29,7 +29,7 @@
2929
sectionsColor: [],
3030
anchors: [],
3131
scrollingSpeed: 700,
32-
easing: 'swing',
32+
easing: 'easeInQuart',
3333
loopBottom: false,
3434
loopTop: false,
3535
css3: true,
@@ -53,6 +53,9 @@
5353
}, options);
5454

5555

56+
//easeInQuart animation included in the plugin
57+
$.extend($.easing,{ easeInQuart: function (x, t, b, c, d) { return c*(t/=d)*t*t*t + b; }});
58+
5659
/**
5760
* Defines the scrolling speed
5861
*/
@@ -249,7 +252,7 @@
249252
}
250253

251254
if(typeof v.anchorLink !== 'undefined'){
252-
setURLHash(v.anchorLink);
255+
setURLHash(v.anchorLink, v.sectionIndex);
253256
}
254257

255258
v.destination.addClass('active').siblings().removeClass('active');
@@ -396,12 +399,30 @@
396399
/**
397400
* Sets the URL hash for a section with slides
398401
*/
399-
function setURLHash(anchorLink){
402+
function setURLHash(anchorLink, sectionIndex){
400403
if(options.anchors.length){
401404
location.hash = anchorLink;
405+
406+
setBodyClass(location.hash);
407+
}else{
408+
setBodyClass(String(sectionIndex));
402409
}
403410
}
404411

412+
/**
413+
* Sets a class for the body of the page depending on the active section / slide
414+
*/
415+
function setBodyClass(text){
416+
//removing the #
417+
text = text.replace('#','');
418+
419+
//removing previous anchor classes
420+
$("body")[0].className = $("body")[0].className.replace(/\b\s?pp-viewing-[^\s]+\b/g, '');
421+
422+
//adding the current anchor
423+
$("body").addClass("pp-viewing-" + text);
424+
}
425+
405426
//TO DO
406427
function scrollToAnchor(){
407428
//getting the anchor link in the URL and deleting the `#`
@@ -662,7 +683,7 @@
662683
function getMSPointer(){
663684
var pointer;
664685

665-
//IE >= 11
686+
//IE >= 11 & rest of browsers
666687
if(window.PointerEvent){
667688
pointer = { down: "pointerdown", move: "pointermove", up: "pointerup"};
668689
}
@@ -681,13 +702,9 @@
681702
*/
682703
function getEventsPage(e){
683704
var events = new Array();
684-
if (window.navigator.msPointerEnabled){
685-
events['y'] = e.pageY;
686-
events['x'] = e.pageX;
687-
}else{
688-
events['y'] = e.touches[0].pageY;
689-
events['x'] = e.touches[0].pageX;
690-
}
705+
706+
events['y'] = (typeof e.pageY !== 'undefined' && (e.pageY || e.pageX) ? e.pageY : e.touches[0].pageY);
707+
events['x'] = (typeof e.pageX !== 'undefined' && (e.pageY || e.pageX) ? e.pageX : e.touches[0].pageX);
691708

692709
return events;
693710
}

0 commit comments

Comments
 (0)