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

Commit 72b4f10

Browse files
crisbetojelbourn
authored andcommitted
fix(datepicker): remove dependency on $mdGesture (#9803)
Removes the datepicker's dependency on `$mdGesture` by inlining the check. This is a preparation for the switch over to HammerJS. Fixes #9793.
1 parent 79d272d commit 72b4f10

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/components/datepicker/js/datepickerDirective.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,16 @@
218218
*/
219219
var CALENDAR_PANE_WIDTH = 360;
220220

221+
/** Used for checking whether the current user agent is on iOS or Android. */
222+
var IS_MOBILE_REGEX = /ipad|iphone|ipod|android/i;
223+
221224
/**
222225
* Controller for md-datepicker.
223226
*
224227
* @ngInject @constructor
225228
*/
226229
function DatePickerCtrl($scope, $element, $attrs, $window, $mdConstant,
227-
$mdTheming, $mdUtil, $mdDateLocale, $$mdDateUtil, $$rAF, $mdGesture, $filter) {
230+
$mdTheming, $mdUtil, $mdDateLocale, $$mdDateUtil, $$rAF, $filter) {
228231

229232
/** @final */
230233
this.$window = $window;
@@ -323,7 +326,9 @@
323326
* the resize event doesn't make sense on mobile and can have a negative impact since it
324327
* triggers whenever the browser zooms in on a focused input.
325328
*/
326-
this.windowEventName = ($mdGesture.isIos || $mdGesture.isAndroid) ? 'orientationchange' : 'resize';
329+
this.windowEventName = IS_MOBILE_REGEX.test(
330+
navigator.userAgent || navigator.vendor || window.opera
331+
) ? 'orientationchange' : 'resize';
327332

328333
/** Pre-bound close handler so that the event listener can be removed. */
329334
this.windowEventHandler = $mdUtil.debounce(angular.bind(this, this.closeCalendarPane), 100);

src/core/services/gesture/gesture.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ function MdGesture($$MdGestureHandler, $$rAF, $timeout) {
7979
var self = {
8080
handler: addHandler,
8181
register: register,
82-
isIos: isIos,
83-
isAndroid: isAndroid,
8482
// On mobile w/out jQuery, we normally intercept clicks. Should we skip that?
8583
isHijackingClicks: (isIos || isAndroid) && !hasJQuery && !forceSkipClickHijack
8684
};

0 commit comments

Comments
 (0)