diff --git a/res/app/components/stf/screen/index.js b/res/app/components/stf/screen/index.js index f06b65f5..4d022d81 100644 --- a/res/app/components/stf/screen/index.js +++ b/res/app/components/stf/screen/index.js @@ -1,5 +1,6 @@ module.exports = angular.module('stf/screen', [ require('stf/screen/scaling').name +, require('stf/util/vendor').name ]) .directive('deviceScreen', require('./screen-directive')) .controller('DeviceScreenCtrl', require('./screen-controller')) diff --git a/res/app/components/stf/screen/screen-directive.js b/res/app/components/stf/screen/screen-directive.js index 7c2cf149..ce23b343 100644 --- a/res/app/components/stf/screen/screen-directive.js +++ b/res/app/components/stf/screen/screen-directive.js @@ -1,6 +1,10 @@ var FastImageRender = require('./fast-image-render').FastImageRender -module.exports = function DeviceScreenDirective($document, ScalingService) { +module.exports = function DeviceScreenDirective( + $document +, ScalingService +, VendorUtil +) { return { restrict: 'E', template: require('./screen.jade'), @@ -18,19 +22,17 @@ module.exports = function DeviceScreenDirective($document, ScalingService) { , loading = false , scaler , seq = 0 + , cssTransform = VendorUtil.style(['transform', 'webkitTransform']) scope.$on('panelsResized', updateDisplaySize) function sendTouch(type, e) { - var scaled = scaler.coords( - displayWidth - , displayHeight - , e.offsetX - , e.offsetY - ) + var x = e.offsetX || e.layerX || 0 + , y = e.offsetY || e.layerY || 0 + , scaled = scaler.coords(displayWidth, displayHeight, x, y) - finger[0].style.webkitTransform = - 'translate3d(' + e.offsetX + 'px,' + e.offsetY + 'px,0)' + finger[0].style[cssTransform] = + 'translate3d(' + x + 'px,' + y + 'px,0)' scope.control[type]( seq++ diff --git a/res/app/components/stf/util/vendor/index.js b/res/app/components/stf/util/vendor/index.js new file mode 100644 index 00000000..59c99858 --- /dev/null +++ b/res/app/components/stf/util/vendor/index.js @@ -0,0 +1,2 @@ +module.exports = angular.module('stf/util/vendor', []) + .factory('VendorUtil', require('./vendor-util')) diff --git a/res/app/components/stf/util/vendor/vendor-util.js b/res/app/components/stf/util/vendor/vendor-util.js new file mode 100644 index 00000000..c2d6d058 --- /dev/null +++ b/res/app/components/stf/util/vendor/vendor-util.js @@ -0,0 +1,15 @@ +module.exports = function VendorUtilFactory() { + var vendorUtil = {} + + vendorUtil.style = function(props) { + var testee = document.createElement('span') + for (var i = 0, l = props.length; i < l; ++i) { + if (testee.style[props[i]] !== void 0) { + return props[i] + } + } + return props[0] + } + + return vendorUtil +}