Permalink
Browse files

css hacks fixed

  • Loading branch information...
jtangelder committed Mar 30, 2012
1 parent fe0c00b commit d31ff66d7aa10d3311eb076e05c0466680e3e970
Showing with 21 additions and 21 deletions.
  1. +21 −21 hammer.js
View
@@ -34,23 +34,26 @@ function Hammer(element, options, undefined)
options = mergeObject(defaults, options);
// some css hacks
var vendors = ['-webkit-','-moz-','-ms-','-o-',''];
var css = element.getAttribute('style') || '';
var css_props = {
"user-select": "none",
"touch-callout": "none",
"user-drag": "none",
"tap-highlight-color": "rgba(0,0,0,0)"
};
(function() {
var vendors = ['webkit','moz','ms','o',''];
var css_props = {
"userSelect": "none",
"touchCallout": "none",
"userDrag": "none",
"tapHighlightColor": "rgba(0,0,0,0)"
};
for(i = 0; i < vendors.length; i++) {
if(supports(vendors[i] + 'user-select')) {
for(var prop in css_props) {
css += vendors[i] + prop + ': ' + css_props[prop] + ';';
var prop = '';
for(i = 0; i < vendors.length; i++) {
for(var p in css_props) {
prop = p;
if(vendors[i]) {
prop = vendors[i] + prop.substring(0, 1).toUpperCase() + prop.substring(1);
}
element.style[ prop ] = css_props[p];
}
}
}
element.setAttribute('style', css);
})();
// holds the distance that has been moved
var _distance = 0;
@@ -236,7 +239,7 @@ function Hammer(element, options, undefined)
_gesture = 'drag';
var position = { x: _pos.move[0].x - _offset.left,
y: _pos.move[0].y - _offset.top };
y: _pos.move[0].y - _offset.top };
var event_obj = {
originalEvent : event,
@@ -277,7 +280,7 @@ function Hammer(element, options, undefined)
_gesture = 'transform';
_pos.center = { x: ((_pos.move[0].x + _pos.move[1].x) / 2) - _offset.left,
y: ((_pos.move[0].y + _pos.move[1].y) / 2) - _offset.top };
y: ((_pos.move[0].y + _pos.move[1].y) / 2) - _offset.top };
var event_obj = {
originalEvent : event,
@@ -311,6 +314,7 @@ function Hammer(element, options, undefined)
// compare the kind of gesture by time
var now = new Date().getTime();
var touch_time = now - _touch_start_time;
var is_double_tap = function () {
if (_prev_tap_pos && options.tap_double && _prev_gesture == 'tap' &&
(_touch_start_time - _prev_tap_end_time) < options.tap_max_interval) {
@@ -380,7 +384,7 @@ function Hammer(element, options, undefined)
var scrollLeft = window.pageXOffset || element.scrollLeft || document.body.scrollLeft;
_offset = {
top: box.top + scrollTop - clientTop,
top: box.top + scrollTop - clientTop,
left: box.left + scrollLeft - clientLeft
};
@@ -485,10 +489,6 @@ function Hammer(element, options, undefined)
return output;
}
function supports( property ){
return document.body.style[property] !== undefined;
}
function isFunction( obj ){
return Object.prototype.toString.call( obj ) == "[object Function]";
}

0 comments on commit d31ff66

Please sign in to comment.