Skip to content

Commit

Permalink
ColumnSet: Remove has("touch") conditions for touch+mouse devices
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth G. Franqueiro committed Mar 17, 2014
1 parent fd95bfb commit 86ad71d
Showing 1 changed file with 41 additions and 46 deletions.
87 changes: 41 additions & 46 deletions ColumnSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,45 +65,42 @@ function(kernel, declare, lang, Deferred, listen, aspect, query, has, miscUtil,
return subset;
}

var horizMouseWheel;
if(!has("touch")){
horizMouseWheel = has("event-mousewheel") || has("event-wheel") ? function(grid){
return function(target, listener){
return listen(target, has("event-wheel") ? "wheel" : "mousewheel", function(event){
var node = event.target, deltaX;
// WebKit will invoke mousewheel handlers with an event target of a text
// node; check target and if it's not an element node, start one node higher
// in the tree
if(node.nodeType !== 1){
node = node.parentNode;
}
while(!query.matches(node, ".dgrid-column-set[" + colsetidAttr + "]", target)){
if(node === target || !(node = node.parentNode)){
return;
}
}

// Normalize reported delta value:
// wheelDeltaX (webkit, mousewheel) needs to be negated and divided by 3
// deltaX (FF17+, wheel) can be used exactly as-is
deltaX = event.deltaX || -event.wheelDeltaX / 3;
if(deltaX){
// only respond to horizontal movement
listener.call(null, grid, node, deltaX);
}
});
};
} : function(grid){
return function(target, listener){
return listen(target, ".dgrid-column-set[" + colsetidAttr + "]:MozMousePixelScroll", function(event){
if(event.axis === 1){
// only respond to horizontal movement
listener.call(null, grid, this, event.detail);
var horizMouseWheel = has("event-mousewheel") || has("event-wheel") ? function(grid){
return function(target, listener){
return listen(target, has("event-wheel") ? "wheel" : "mousewheel", function(event){
var node = event.target, deltaX;
// WebKit will invoke mousewheel handlers with an event target of a text
// node; check target and if it's not an element node, start one node higher
// in the tree
if(node.nodeType !== 1){
node = node.parentNode;
}
while(!query.matches(node, ".dgrid-column-set[" + colsetidAttr + "]", target)){
if(node === target || !(node = node.parentNode)){
return;
}
});
};
}

// Normalize reported delta value:
// wheelDeltaX (webkit, mousewheel) needs to be negated and divided by 3
// deltaX (FF17+, wheel) can be used exactly as-is
deltaX = event.deltaX || -event.wheelDeltaX / 3;
if(deltaX){
// only respond to horizontal movement
listener.call(null, grid, node, deltaX);
}
});
};
}
} : function(grid){
return function(target, listener){
return listen(target, ".dgrid-column-set[" + colsetidAttr + "]:MozMousePixelScroll", function(event){
if(event.axis === 1){
// only respond to horizontal movement
listener.call(null, grid, this, event.detail);
}
});
};
};

return declare(null, {
// summary:
Expand All @@ -114,15 +111,13 @@ function(kernel, declare, lang, Deferred, listen, aspect, query, has, miscUtil,
postCreate: function(){
this.inherited(arguments);

if(!has("touch")){
this.on(horizMouseWheel(this), function(grid, colsetNode, amount){
var id = colsetNode.getAttribute(colsetidAttr),
scroller = grid._columnSetScrollers[id],
scrollLeft = scroller.scrollLeft + amount;

scroller.scrollLeft = scrollLeft < 0 ? 0 : scrollLeft;
});
}
this.on(horizMouseWheel(this), function(grid, colsetNode, amount){
var id = colsetNode.getAttribute(colsetidAttr),
scroller = grid._columnSetScrollers[id],
scrollLeft = scroller.scrollLeft + amount;

scroller.scrollLeft = scrollLeft < 0 ? 0 : scrollLeft;
});
},
columnSets: [],
createRowCells: function(tag, each, subRows, object){
Expand Down

0 comments on commit 86ad71d

Please sign in to comment.