Skip to content

Commit 9182067

Browse files
committed
Updated the Carousel to fire the onDragStart once there's actual movement (vs drag initialized)
1 parent 66d05b1 commit 9182067

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

src/carousel/Carousel.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -954,15 +954,15 @@ javaxt.dhtml.Carousel = function(parent, config) {
954954
var startX, offsetX;
955955
var prevPanel;
956956

957+
var notify = true;
958+
957959
//Function called when a drag is initiated
958960
var onDragStart = function(e){
959-
me.onDragStart(currPanel.childNodes[0].childNodes[0]);
960961

961962
startX = e.clientX;
962963
offsetX = parseInt(innerDiv.style.left);
963964

964965

965-
966966
//Disable text selection in the entire document - very important!
967967
var body = document.getElementsByTagName('body')[0];
968968
if (!body.className.match(/(?:^|\s)javaxt-noselect(?!\S)/) ){
@@ -971,7 +971,6 @@ javaxt.dhtml.Carousel = function(parent, config) {
971971

972972

973973
prevPanel = currPanel;
974-
innerDiv.style.cursor = config.dragCursor;
975974
};
976975

977976

@@ -983,6 +982,19 @@ javaxt.dhtml.Carousel = function(parent, config) {
983982
//Otherwise, client is sliding to the left.
984983

985984

985+
//Fire onDragStart event once we actually have some movement
986+
if (notify){
987+
if (d!==0){
988+
me.onDragStart(currPanel.childNodes[0].childNodes[0]);
989+
notify = false;
990+
}
991+
}
992+
993+
994+
//Update cursor style
995+
innerDiv.style.cursor = config.dragCursor;
996+
997+
986998
var left = offsetX-d;
987999
innerDiv.style.left = left + 'px';
9881000

@@ -1057,6 +1069,7 @@ javaxt.dhtml.Carousel = function(parent, config) {
10571069

10581070
//Function called when the user stops dragging the div
10591071
var onDragEnd = function(){
1072+
notify = true;
10601073

10611074
var rect = _getRect(outerDiv);
10621075
var minX = rect.x;

0 commit comments

Comments
 (0)