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

Commit

Permalink
fix(jQuery touchdrag): special-case jQuery touch drag events
Browse files Browse the repository at this point in the history
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
  • Loading branch information
SomeKittens committed Sep 12, 2015
1 parent c295344 commit 8418ea5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/ui-layout.js
Expand Up @@ -4,7 +4,7 @@
* UI.Layout
*/
angular.module('ui.layout', [])
.controller('uiLayoutCtrl', ['$scope', '$attrs', '$element', '$timeout', 'LayoutContainer', function uiLayoutCtrl($scope, $attrs, $element, $timeout, LayoutContainer) {
.controller('uiLayoutCtrl', ['$scope', '$attrs', '$element', '$timeout', '$window', 'LayoutContainer', function uiLayoutCtrl($scope, $attrs, $element, $timeout, $window, LayoutContainer) {
var ctrl = this;
var opts = angular.extend({}, $scope.$eval($attrs.uiLayout), $scope.$eval($attrs.options));
var numOfSplitbars = 0;
Expand Down Expand Up @@ -141,7 +141,10 @@ angular.module('ui.layout', [])
ctrl.mouseMoveHandler = function(mouseEvent) {
var mousePos = mouseEvent[ctrl.sizeProperties.mouseProperty] ||
(mouseEvent.originalEvent && mouseEvent.originalEvent[ctrl.sizeProperties.mouseProperty]) ||
(mouseEvent.targetTouches ? mouseEvent.targetTouches[0][ctrl.sizeProperties.mouseProperty] : 0);
// jQuery does touches weird, see #82
($window.jQuery ?
(mouseEvent.originalEvent ? mouseEvent.originalEvent.targetTouches[0][ctrl.sizeProperties.mouseProperty] : 0) :
(mouseEvent.targetTouches ? mouseEvent.targetTouches[0][ctrl.sizeProperties.mouseProperty] : 0));

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

Expand Down

0 comments on commit 8418ea5

Please sign in to comment.