mirror of
https://github.com/openstf/stf
synced 2025-10-05 19:42:01 +02:00
Fix touch control not working in Firefox.
This commit is contained in:
parent
272301d519
commit
b9e4cfc10d
4 changed files with 29 additions and 9 deletions
|
@ -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'))
|
||||
|
|
|
@ -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++
|
||||
|
|
2
res/app/components/stf/util/vendor/index.js
vendored
Normal file
2
res/app/components/stf/util/vendor/index.js
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = angular.module('stf/util/vendor', [])
|
||||
.factory('VendorUtil', require('./vendor-util'))
|
15
res/app/components/stf/util/vendor/vendor-util.js
vendored
Normal file
15
res/app/components/stf/util/vendor/vendor-util.js
vendored
Normal file
|
@ -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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue