@@ -100,12 +100,18 @@ javaxt.dhtml.Carousel = function(parent, config) {
100
100
slideOver : false ,
101
101
102
102
103
- /** If true, will allow touchscreen users to slide back and forth through
104
- * the panels using touch gestures.
103
+ /** If true, will allow users to slide back and forth through the panels
104
+ * using touch gestures.
105
105
*/
106
106
drag : true ,
107
107
108
108
109
+ /** Cursor style when dragging. Only applicable when "drag" is set to
110
+ * true.
111
+ */
112
+ dragCursor : "ew-resize" , //grabbing
113
+
114
+
109
115
/** Currently unused
110
116
*/
111
117
visiblePanels : 1 ,
@@ -844,6 +850,24 @@ javaxt.dhtml.Carousel = function(parent, config) {
844
850
this . beforeChange = function ( currPanel , nextPanel , direction ) { } ;
845
851
846
852
853
+ //**************************************************************************
854
+ //** onDragStart
855
+ //**************************************************************************
856
+ /** Called when a client begins to drag a panel in the carousel
857
+ * @param currPanel Content of the active panel
858
+ */
859
+ this . onDragStart = function ( currPanel ) { } ;
860
+
861
+
862
+ //**************************************************************************
863
+ //** onDragEnd
864
+ //**************************************************************************
865
+ /** Called when a client completes a drag event
866
+ * @param currPanel Content of the active panel
867
+ */
868
+ this . onDragEnd = function ( currPanel ) { } ;
869
+
870
+
847
871
//**************************************************************************
848
872
//** getPanels
849
873
//**************************************************************************
@@ -932,6 +956,8 @@ javaxt.dhtml.Carousel = function(parent, config) {
932
956
933
957
//Function called when a drag is initiated
934
958
var onDragStart = function ( e ) {
959
+ me . onDragStart ( currPanel . childNodes [ 0 ] . childNodes [ 0 ] ) ;
960
+
935
961
startX = e . clientX ;
936
962
offsetX = parseInt ( innerDiv . style . left ) ;
937
963
@@ -945,7 +971,7 @@ javaxt.dhtml.Carousel = function(parent, config) {
945
971
946
972
947
973
prevPanel = currPanel ;
948
- innerDiv . style . cursor = 'move' ;
974
+ innerDiv . style . cursor = config . dragCursor ;
949
975
} ;
950
976
951
977
@@ -1082,10 +1108,17 @@ javaxt.dhtml.Carousel = function(parent, config) {
1082
1108
if ( animationSteps < 0 ) animationSteps = - animationSteps ;
1083
1109
//console.log(start + "/" + end + " --> move " + (start-end) + "px in " + animationSteps + "ms");
1084
1110
1111
+ var direction = ( start - end ) > 0 ? "next" : "back" ;
1112
+
1113
+
1114
+
1085
1115
slide ( innerDiv , start , end , new Date ( ) . getTime ( ) , 100 , function ( ) {
1086
1116
currPanel = innerDiv . childNodes [ visiblePanel ] ;
1117
+ var nextPanel = currPanel . childNodes [ 0 ] . childNodes [ 0 ] ;
1118
+ me . onDragEnd ( nextPanel ) ;
1087
1119
if ( currPanel != prevPanel ) {
1088
- me . onChange ( currPanel . childNodes [ 0 ] . childNodes [ 0 ] , prevPanel . childNodes [ 0 ] . childNodes [ 0 ] ) ;
1120
+ me . beforeChange ( prevPanel . childNodes [ 0 ] . childNodes [ 0 ] , nextPanel , direction ) ;
1121
+ me . onChange ( nextPanel , prevPanel . childNodes [ 0 ] . childNodes [ 0 ] ) ;
1089
1122
}
1090
1123
} ) ;
1091
1124
@@ -1108,6 +1141,7 @@ javaxt.dhtml.Carousel = function(parent, config) {
1108
1141
//MouseDown
1109
1142
innerDiv . onmousedown = function ( e ) {
1110
1143
if ( sliding ) return ;
1144
+ if ( e . button > 0 ) return ;
1111
1145
1112
1146
// Do not take any immediate action - just set the holdStarter
1113
1147
// to wait for the predetermined delay, and then begin a hold
@@ -1162,7 +1196,7 @@ javaxt.dhtml.Carousel = function(parent, config) {
1162
1196
document . detachEvent ( "onmousemove" , onDrag ) ;
1163
1197
document . detachEvent ( "onmouseup" , onMouseUp ) ;
1164
1198
}
1165
- innerDiv . style . cursor = 'pointer ' ;
1199
+ innerDiv . style . cursor = '' ;
1166
1200
onDragEnd ( ) ;
1167
1201
1168
1202
//Remove the "javaxt-noselect" class
0 commit comments