Skip to content

Commit

Permalink
Merge pull request #34 from elliottregan/touchevents-fix
Browse files Browse the repository at this point in the history
bug fix: touch start events on iOS devices works
  • Loading branch information
jseppi committed Oct 23, 2014
2 parents 138cac1 + 238ddfe commit c97b0dc
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
6 changes: 5 additions & 1 deletion angular-dropdowns.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
margin: 0 auto;
padding: 10px;

-webkit-user-select:none;
-moz-user-select:none;
user-select:none;

/* Styles */
background: #fff;
border-radius: 7px;
Expand Down Expand Up @@ -212,4 +216,4 @@
.wrap-dd-menu .dropdown.active {
opacity: 1;
pointer-events: auto;
}
}
7 changes: 4 additions & 3 deletions angular-dropdowns.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ dd.directive('dropdownSelect', ['DropdownService', '$window',
});
};

var $clickEvent = ('ontouchstart' in $window ? 'touchend' : 'click');
// Does not register touchstart events outside of directive scope
var $clickEvent = ('click'||'touchstart' in $window);
$element.bind($clickEvent, function (event) {
event.stopPropagation();
DropdownService.toggleActive($element);
Expand Down Expand Up @@ -103,7 +104,8 @@ dd.directive('dropdownMenu', ['$parse', '$compile', 'DropdownService', '$window'
controller: ['$scope', '$element', '$attrs', function ($scope, $element, $attrs) {
$scope.labelField = $attrs.dropdownItemLabel || 'text';

var $clickEvent = ('ontouchstart' in $window ? 'touchend' : 'click');
// Does not register touchstart events outside of directive scope.
var $clickEvent = ('click'||'touchstart'in $window);
var $template = angular.element([
'<ul class="dropdown">',
'<li ng-repeat="item in dropdownMenu"',
Expand Down Expand Up @@ -170,7 +172,6 @@ dd.directive('dropdownMenuItem', [
'<li ng-class="{divider: dropdownMenuItem.divider}">',
'<a href="" class="dropdown-item"',
' ng-if="!dropdownMenuItem.divider"',
' ng-href="{{dropdownMenuItem.href}}"',
' ng-click="selectItem()">',
'{{dropdownMenuItem[dropdownItemLabel]}}',
'</a>',
Expand Down
6 changes: 5 additions & 1 deletion dist/angular-dropdowns.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
margin: 0 auto;
padding: 10px;

-webkit-user-select:none;
-moz-user-select:none;
user-select:none;

/* Styles */
background: #fff;
border-radius: 7px;
Expand Down Expand Up @@ -212,4 +216,4 @@
.wrap-dd-menu .dropdown.active {
opacity: 1;
pointer-events: auto;
}
}
7 changes: 4 additions & 3 deletions dist/angular-dropdowns.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ dd.directive('dropdownSelect', ['DropdownService', '$window',
});
};

var $clickEvent = ('ontouchstart' in $window ? 'touchend' : 'click');
// Does not register touchstart events outside of directive scope
var $clickEvent = ('click'||'touchstart' in $window);
$element.bind($clickEvent, function (event) {
event.stopPropagation();
DropdownService.toggleActive($element);
Expand Down Expand Up @@ -103,7 +104,8 @@ dd.directive('dropdownMenu', ['$parse', '$compile', 'DropdownService', '$window'
controller: ['$scope', '$element', '$attrs', function ($scope, $element, $attrs) {
$scope.labelField = $attrs.dropdownItemLabel || 'text';

var $clickEvent = ('ontouchstart' in $window ? 'touchend' : 'click');
// Does not register touchstart events outside of directive scope.
var $clickEvent = ('click'||'touchstart'in $window);
var $template = angular.element([
'<ul class="dropdown">',
'<li ng-repeat="item in dropdownMenu"',
Expand Down Expand Up @@ -170,7 +172,6 @@ dd.directive('dropdownMenuItem', [
'<li ng-class="{divider: dropdownMenuItem.divider}">',
'<a href="" class="dropdown-item"',
' ng-if="!dropdownMenuItem.divider"',
' ng-href="{{dropdownMenuItem.href}}"',
' ng-click="selectItem()">',
'{{dropdownMenuItem[dropdownItemLabel]}}',
'</a>',
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-dropdowns.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c97b0dc

Please sign in to comment.