move touch.js to canvas
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
import './components/index.js'
|
||||
import './dialogs/index.js'
|
||||
|
||||
import './touch.js'
|
||||
import { isMac } from '../common/browser.js'
|
||||
|
||||
import SvgCanvas from '../svgcanvas/svgcanvas.js'
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* globals seConfirm seAlert */
|
||||
import './touch.js'
|
||||
import { convertUnit } from '../common/units.js'
|
||||
import {
|
||||
putLocale
|
||||
|
||||
@@ -443,13 +443,6 @@ export default {
|
||||
header.textContent = allLibs
|
||||
back.style.display = 'none'
|
||||
})
|
||||
back.addEventListener('touchend', function () {
|
||||
frame.setAttribute('src', 'about:blank')
|
||||
frame.style.display = 'none'
|
||||
libOpts.style.display = 'block'
|
||||
header.textContent = allLibs
|
||||
back.style.display = 'none'
|
||||
})
|
||||
back.setAttribute('style', 'margin-right: 5px;')
|
||||
back.style.display = 'none'
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
// http://ross.posterous.com/2008/08/19/iphone-touch-events-in-javascript/
|
||||
/**
|
||||
*
|
||||
* @param {Event} ev
|
||||
* @returns {void}
|
||||
*/
|
||||
function touchHandler (ev) {
|
||||
const { changedTouches } = ev
|
||||
const first = changedTouches[0]
|
||||
|
||||
let type = ''
|
||||
switch (ev.type) {
|
||||
case 'touchstart': type = 'mousedown'; break
|
||||
case 'touchmove': type = 'mousemove'; break
|
||||
case 'touchend': type = 'mouseup'; break
|
||||
default: return
|
||||
}
|
||||
|
||||
const { screenX, screenY, clientX, clientY } = first
|
||||
const simulatedEvent = new MouseEvent(type, {
|
||||
// Event interface
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
// UIEvent interface
|
||||
view: window,
|
||||
detail: 1, // click count
|
||||
// MouseEvent interface (customized)
|
||||
screenX,
|
||||
screenY,
|
||||
clientX,
|
||||
clientY,
|
||||
// MouseEvent interface (defaults) - these could be removed
|
||||
ctrlKey: false,
|
||||
altKey: false,
|
||||
shiftKey: false,
|
||||
metaKey: false,
|
||||
button: 0, // main button (usually left)
|
||||
relatedTarget: null
|
||||
})
|
||||
if (changedTouches.length < 2) {
|
||||
first.target.dispatchEvent(simulatedEvent)
|
||||
ev.preventDefault()
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('touchstart', touchHandler, true)
|
||||
document.addEventListener('touchmove', touchHandler, true)
|
||||
document.addEventListener('touchend', touchHandler, true)
|
||||
document.addEventListener('touchcancel', touchHandler, true)
|
||||
Reference in New Issue
Block a user