@@ -678,6 +678,12 @@ ionic.views.Scroll = ionic.views.View.inherit({
678
678
ionic . scroll . isScrolling = false ;
679
679
} ) ;
680
680
681
+ function getEventTouches ( e ) {
682
+ return e . touches && e . touches . length ? e . touches : [ {
683
+ pageX : e . pageX ,
684
+ pageY : e . pageY
685
+ } ] ;
686
+ }
681
687
682
688
self . touchStart = function ( e ) {
683
689
self . startCoordinates = getPointerCoordinates ( e ) ;
@@ -686,6 +692,8 @@ ionic.views.Scroll = ionic.views.View.inherit({
686
692
return ;
687
693
}
688
694
695
+ self . __isDown = true ;
696
+
689
697
if ( ionic . tap . containsOrIsTextInput ( e . target ) || e . target . tagName === 'SELECT' ) {
690
698
// do not start if the target is a text input
691
699
// if there is a touchmove on this input, then we can start the scroll
@@ -696,12 +704,13 @@ ionic.views.Scroll = ionic.views.View.inherit({
696
704
self . __isSelectable = true ;
697
705
self . __enableScrollY = true ;
698
706
self . __hasStarted = true ;
699
- self . doTouchStart ( e . touches , e . timeStamp ) ;
707
+ self . doTouchStart ( getEventTouches ( e ) , e . timeStamp ) ;
700
708
e . preventDefault ( ) ;
701
709
} ;
702
710
703
711
self . touchMove = function ( e ) {
704
- if ( e . defaultPrevented ||
712
+ if ( ! self . __isDown ||
713
+ e . defaultPrevented ||
705
714
( e . target . tagName === 'TEXTAREA' && e . target . parentElement . querySelector ( ':focus' ) ) ) {
706
715
return ;
707
716
}
@@ -710,7 +719,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
710
719
// the target is a text input and scroll has started
711
720
// since the text input doesn't start on touchStart, do it here
712
721
self . __hasStarted = true ;
713
- self . doTouchStart ( e . touches , e . timeStamp ) ;
722
+ self . doTouchStart ( getEventTouches ( e ) , e . timeStamp ) ;
714
723
e . preventDefault ( ) ;
715
724
return ;
716
725
}
@@ -736,11 +745,15 @@ ionic.views.Scroll = ionic.views.View.inherit({
736
745
}
737
746
}
738
747
739
- self . doTouchMove ( e . touches , e . timeStamp , e . scale ) ;
748
+ self . doTouchMove ( getEventTouches ( e ) , e . timeStamp , e . scale ) ;
749
+ self . __isDown = true ;
740
750
} ;
741
751
742
752
self . touchEnd = function ( e ) {
753
+ if ( ! self . __isDown ) return ;
754
+
743
755
self . doTouchEnd ( e . timeStamp ) ;
756
+ self . __isDown = false ;
744
757
self . __hasStarted = false ;
745
758
self . __isSelectable = true ;
746
759
self . __enableScrollY = true ;
@@ -756,25 +769,36 @@ ionic.views.Scroll = ionic.views.View.inherit({
756
769
self . options . orgScrollingComplete ( ) ;
757
770
} ;
758
771
759
-
760
772
if ( 'ontouchstart' in window ) {
773
+ // Touch Events
761
774
container . addEventListener ( "touchstart" , self . touchStart , false ) ;
762
775
document . addEventListener ( "touchmove" , self . touchMove , false ) ;
763
776
document . addEventListener ( "touchend" , self . touchEnd , false ) ;
764
777
document . addEventListener ( "touchcancel" , self . touchEnd , false ) ;
765
778
766
- } else {
779
+ } else if ( window . navigator . pointerEnabled ) {
780
+ // Pointer Events
781
+ container . addEventListener ( "pointerdown" , self . touchStart , false ) ;
782
+ document . addEventListener ( "pointermove" , self . touchMove , false ) ;
783
+ document . addEventListener ( "pointerup" , self . touchEnd , false ) ;
784
+ document . addEventListener ( "pointercancel" , self . touchEnd , false ) ;
785
+
786
+ } else if ( window . navigator . msPointerEnabled ) {
787
+ // IE10, WP8 (Pointer Events)
788
+ container . addEventListener ( "MSPointerDown" , self . touchStart , false ) ;
789
+ document . addEventListener ( "MSPointerMove" , self . touchMove , false ) ;
790
+ document . addEventListener ( "MSPointerUp" , self . touchEnd , false ) ;
791
+ document . addEventListener ( "MSPointerCancel" , self . touchEnd , false ) ;
767
792
793
+ } else {
794
+ // Mouse Events
768
795
var mousedown = false ;
769
796
770
797
container . addEventListener ( "mousedown" , function ( e ) {
771
798
if ( ionic . tap . ignoreScrollStart ( e ) || e . target . tagName === 'SELECT' ) {
772
799
return ;
773
800
}
774
- self . doTouchStart ( [ {
775
- pageX : e . pageX ,
776
- pageY : e . pageY
777
- } ] , e . timeStamp ) ;
801
+ self . doTouchStart ( getEventTouches ( e ) , e . timeStamp ) ;
778
802
779
803
e . preventDefault ( ) ;
780
804
mousedown = true ;
@@ -785,10 +809,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
785
809
return ;
786
810
}
787
811
788
- self . doTouchMove ( [ {
789
- pageX : e . pageX ,
790
- pageY : e . pageY
791
- } ] , e . timeStamp ) ;
812
+ self . doTouchMove ( getEventTouches ( e ) , e . timeStamp ) ;
792
813
793
814
mousedown = true ;
794
815
} , false ) ;
@@ -1476,16 +1497,11 @@ ionic.views.Scroll = ionic.views.View.inherit({
1476
1497
doTouchStart : function ( touches , timeStamp ) {
1477
1498
this . hintResize ( ) ;
1478
1499
1479
- // Array-like check is enough here
1480
- if ( touches . length == null ) {
1481
- throw new Error ( "Invalid touch list: " + touches ) ;
1482
- }
1483
-
1484
1500
if ( timeStamp instanceof Date ) {
1485
1501
timeStamp = timeStamp . valueOf ( ) ;
1486
1502
}
1487
1503
if ( typeof timeStamp !== "number" ) {
1488
- throw new Error ( "Invalid timestamp value: " + timeStamp ) ;
1504
+ timeStamp = Date . now ( ) ;
1489
1505
}
1490
1506
1491
1507
var self = this ;
@@ -1561,17 +1577,11 @@ ionic.views.Scroll = ionic.views.View.inherit({
1561
1577
* Touch move handler for scrolling support
1562
1578
*/
1563
1579
doTouchMove : function ( touches , timeStamp , scale ) {
1564
-
1565
- // Array-like check is enough here
1566
- if ( touches . length == null ) {
1567
- throw new Error ( "Invalid touch list: " + touches ) ;
1568
- }
1569
-
1570
1580
if ( timeStamp instanceof Date ) {
1571
1581
timeStamp = timeStamp . valueOf ( ) ;
1572
1582
}
1573
1583
if ( typeof timeStamp !== "number" ) {
1574
- throw new Error ( "Invalid timestamp value: " + timeStamp ) ;
1584
+ timeStamp = Date . now ( ) ;
1575
1585
}
1576
1586
1577
1587
var self = this ;
@@ -1581,7 +1591,6 @@ ionic.views.Scroll = ionic.views.View.inherit({
1581
1591
return ;
1582
1592
}
1583
1593
1584
-
1585
1594
var currentTouchLeft , currentTouchTop ;
1586
1595
1587
1596
// Compute move based around of center of fingers
@@ -1750,12 +1759,11 @@ ionic.views.Scroll = ionic.views.View.inherit({
1750
1759
* Touch end handler for scrolling support
1751
1760
*/
1752
1761
doTouchEnd : function ( timeStamp ) {
1753
-
1754
1762
if ( timeStamp instanceof Date ) {
1755
1763
timeStamp = timeStamp . valueOf ( ) ;
1756
1764
}
1757
1765
if ( typeof timeStamp !== "number" ) {
1758
- throw new Error ( "Invalid timestamp value: " + timeStamp ) ;
1766
+ timeStamp = Date . now ( ) ;
1759
1767
}
1760
1768
1761
1769
var self = this ;
0 commit comments