Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : #768 issue #770

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix : #768 issue
  • Loading branch information
sculove committed Mar 17, 2015
commit b047957a5a798062603e565f5fa1119a9958f4b0
35 changes: 20 additions & 15 deletions hammer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*! Hammer.JS - v2.0.4 - 2014-09-28
/*! Hammer.JS - v2.0.4 - 2015-03-17
* http://hammerjs.github.io/
*
* Copyright (c) 2014 Jorik Tangelder;
* Copyright (c) 2015 Jorik Tangelder;
* Licensed under the MIT license */
(function(window, document, exportName, undefined) {
'use strict';
Expand Down Expand Up @@ -320,8 +320,8 @@ function uniqueId() {
* @returns {DocumentView|Window}
*/
function getWindowForElement(element) {
var doc = element.ownerDocument;
return (doc.defaultView || doc.parentWindow);
var doc = element.ownerDocument || element;
return (doc.defaultView || doc.parentWindow || window);
}

var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
Expand Down Expand Up @@ -1114,7 +1114,7 @@ TouchAction.prototype = {
value = this.compute();
}

if (NATIVE_TOUCH_ACTION) {
if (NATIVE_TOUCH_ACTION && this.manager.element.style) {
this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
}
this.actions = value.toLowerCase().trim();
Expand Down Expand Up @@ -1981,7 +1981,7 @@ inherit(TapRecognizer, Recognizer, {
},

emit: function() {
if (this.state == STATE_RECOGNIZED ) {
if (this.state == STATE_RECOGNIZED) {
this._input.tapCount = this.count;
this.manager.emit(this.options.event, this._input);
}
Expand Down Expand Up @@ -2055,12 +2055,12 @@ Hammer.defaults = {
*/
preset: [
// RecognizerClass, options, [recognizeWith, ...], [requireFailure, ...]
[RotateRecognizer, { enable: false }],
[PinchRecognizer, { enable: false }, ['rotate']],
[SwipeRecognizer,{ direction: DIRECTION_HORIZONTAL }],
[PanRecognizer, { direction: DIRECTION_HORIZONTAL }, ['swipe']],
[RotateRecognizer, {enable: false}],
[PinchRecognizer, {enable: false}, ['rotate']],
[SwipeRecognizer, {direction: DIRECTION_HORIZONTAL}],
[PanRecognizer, {direction: DIRECTION_HORIZONTAL}, ['swipe']],
[TapRecognizer],
[TapRecognizer, { event: 'doubletap', taps: 2 }, ['tap']],
[TapRecognizer, {event: 'doubletap', taps: 2}, ['tap']],
[PressRecognizer]
],

Expand Down Expand Up @@ -2322,10 +2322,12 @@ Manager.prototype = {
off: function(events, handler) {
var handlers = this.handlers;
each(splitStr(events), function(event) {
if (!handler) {
delete handlers[event];
} else {
handlers[event].splice(inArray(handlers[event], handler), 1);
if (typeof handlers[event] !== 'undefined') {
if (!handler) {
delete handlers[event];
} else {
handlers[event].splice(inArray(handlers[event], handler), 1);
}
}
});
return this;
Expand Down Expand Up @@ -2381,6 +2383,9 @@ Manager.prototype = {
*/
function toggleCssProps(manager, add) {
var element = manager.element;
if (!element.style) {
return;
}
each(manager.options.cssProps, function(value, name) {
element.style[prefixed(element.style, name)] = add ? value : '';
});
Expand Down
Loading