Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit 8418ea5

Browse files
committed
fix(jQuery touchdrag): special-case jQuery touch drag events
Previously, jQuery altered the event object so we thought the mousePosition was always zero. Special-case jQuery so that we're grabbing the correct mousePosition. Fixes #82
1 parent c295344 commit 8418ea5

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎src/ui-layout.js‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* UI.Layout
55
*/
66
angular.module('ui.layout', [])
7-
.controller('uiLayoutCtrl', ['$scope', '$attrs', '$element', '$timeout', 'LayoutContainer', function uiLayoutCtrl($scope, $attrs, $element, $timeout, LayoutContainer) {
7+
.controller('uiLayoutCtrl', ['$scope', '$attrs', '$element', '$timeout', '$window', 'LayoutContainer', function uiLayoutCtrl($scope, $attrs, $element, $timeout, $window, LayoutContainer) {
88
var ctrl = this;
99
var opts = angular.extend({}, $scope.$eval($attrs.uiLayout), $scope.$eval($attrs.options));
1010
var numOfSplitbars = 0;
@@ -141,7 +141,10 @@ angular.module('ui.layout', [])
141141
ctrl.mouseMoveHandler = function(mouseEvent) {
142142
var mousePos = mouseEvent[ctrl.sizeProperties.mouseProperty] ||
143143
(mouseEvent.originalEvent && mouseEvent.originalEvent[ctrl.sizeProperties.mouseProperty]) ||
144-
(mouseEvent.targetTouches ? mouseEvent.targetTouches[0][ctrl.sizeProperties.mouseProperty] : 0);
144+
// jQuery does touches weird, see #82
145+
($window.jQuery ?
146+
(mouseEvent.originalEvent ? mouseEvent.originalEvent.targetTouches[0][ctrl.sizeProperties.mouseProperty] : 0) :
147+
(mouseEvent.targetTouches ? mouseEvent.targetTouches[0][ctrl.sizeProperties.mouseProperty] : 0));
145148

146149
lastPos = mousePos - offset($element)[ctrl.sizeProperties.offsetPos];
147150

0 commit comments

Comments
 (0)