move touch.js to canvas
parent
2d5104cdeb
commit
b9a89a9789
|
@ -15,7 +15,6 @@ const isWebkit_ = userAgent.includes('AppleWebKit')
|
||||||
const isGecko_ = userAgent.includes('Gecko/')
|
const isGecko_ = userAgent.includes('Gecko/')
|
||||||
const isChrome_ = userAgent.includes('Chrome/')
|
const isChrome_ = userAgent.includes('Chrome/')
|
||||||
const isMac_ = userAgent.includes('Macintosh')
|
const isMac_ = userAgent.includes('Macintosh')
|
||||||
const isTouch_ = 'ontouchstart' in window
|
|
||||||
|
|
||||||
// text character positioning (for IE9 and now Chrome)
|
// text character positioning (for IE9 and now Chrome)
|
||||||
const supportsGoodTextCharPos_ = (function () {
|
const supportsGoodTextCharPos_ = (function () {
|
||||||
|
@ -60,11 +59,6 @@ export const isChrome = () => isChrome_
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
export const isMac = () => isMac_
|
export const isMac = () => isMac_
|
||||||
/**
|
|
||||||
* @function module:browser.isTouch
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
export const isTouch = () => isTouch_
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function module:browser.supportsGoodTextCharPos
|
* @function module:browser.supportsGoodTextCharPos
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
import './components/index.js'
|
import './components/index.js'
|
||||||
import './dialogs/index.js'
|
import './dialogs/index.js'
|
||||||
|
|
||||||
import './touch.js'
|
|
||||||
import { isMac } from '../common/browser.js'
|
import { isMac } from '../common/browser.js'
|
||||||
|
|
||||||
import SvgCanvas from '../svgcanvas/svgcanvas.js'
|
import SvgCanvas from '../svgcanvas/svgcanvas.js'
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
/* globals seConfirm seAlert */
|
/* globals seConfirm seAlert */
|
||||||
import './touch.js'
|
|
||||||
import { convertUnit } from '../common/units.js'
|
import { convertUnit } from '../common/units.js'
|
||||||
import {
|
import {
|
||||||
putLocale
|
putLocale
|
||||||
|
|
|
@ -443,13 +443,6 @@ export default {
|
||||||
header.textContent = allLibs
|
header.textContent = allLibs
|
||||||
back.style.display = 'none'
|
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.setAttribute('style', 'margin-right: 5px;')
|
||||||
back.style.display = 'none'
|
back.style.display = 'none'
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,14 @@
|
||||||
* @copyright 2010 Alexis Deveria, 2010 Jeff Schiller
|
* @copyright 2010 Alexis Deveria, 2010 Jeff Schiller
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { isTouch, isWebkit } from '../common/browser.js' // , isOpera
|
import { isWebkit } from '../common/browser.js' // , isOpera
|
||||||
import { getRotationAngle, getBBox, getStrokedBBox } from './utilities.js'
|
import { getRotationAngle, getBBox, getStrokedBBox } from './utilities.js'
|
||||||
import { transformListToTransform, transformBox, transformPoint } from './math.js'
|
import { transformListToTransform, transformBox, transformPoint } from './math.js'
|
||||||
|
|
||||||
let svgCanvas
|
let svgCanvas
|
||||||
let selectorManager_ // A Singleton
|
let selectorManager_ // A Singleton
|
||||||
const gripRadius = isTouch() ? 10 : 4
|
// change radius if touch screen
|
||||||
|
const gripRadius = window.ontouchstart ? 10 : 4
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private class for DOM element selection boxes.
|
* Private class for DOM element selection boxes.
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
* @copyright 2010 Alexis Deveria, 2010 Pavol Rusnak, 2010 Jeff Schiller, 2021 OptimistikSAS
|
* @copyright 2010 Alexis Deveria, 2010 Pavol Rusnak, 2010 Jeff Schiller, 2021 OptimistikSAS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Canvg as canvg } from 'canvg'
|
import { Canvg as canvg } from 'canvg'
|
||||||
import 'pathseg' // SVGPathSeg Polyfill (see https://github.com/progers/pathseg)
|
import 'pathseg' // SVGPathSeg Polyfill (see https://github.com/progers/pathseg)
|
||||||
|
|
||||||
|
@ -17,6 +16,7 @@ import * as draw from './draw.js'
|
||||||
import {
|
import {
|
||||||
init as pasteInit, pasteElementsMethod
|
init as pasteInit, pasteElementsMethod
|
||||||
} from './paste-elem.js'
|
} from './paste-elem.js'
|
||||||
|
import { init as touchInit } from './touch.js'
|
||||||
import { svgRootElement } from './svgroot.js'
|
import { svgRootElement } from './svgroot.js'
|
||||||
import {
|
import {
|
||||||
init as undoInit, changeSelectedAttributeNoUndoMethod,
|
init as undoInit, changeSelectedAttributeNoUndoMethod,
|
||||||
|
@ -162,6 +162,7 @@ class SvgCanvas {
|
||||||
container.append(this.svgroot)
|
container.append(this.svgroot)
|
||||||
// The actual element that represents the final output SVG element.
|
// The actual element that represents the final output SVG element.
|
||||||
this.svgContent = this.svgdoc.createElementNS(NS.SVG, 'svg')
|
this.svgContent = this.svgdoc.createElementNS(NS.SVG, 'svg')
|
||||||
|
touchInit(this)
|
||||||
clearInit(this)
|
clearInit(this)
|
||||||
this.clearSvgContentElement()
|
this.clearSvgContentElement()
|
||||||
// Current `draw.Drawing` object.
|
// Current `draw.Drawing` object.
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* @param {Event} ev
|
* @param {Event} ev
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function touchHandler (ev) {
|
const touchHandler = (ev) => {
|
||||||
const { changedTouches } = ev
|
const { changedTouches } = ev
|
||||||
const first = changedTouches[0]
|
const first = changedTouches[0]
|
||||||
|
|
||||||
|
@ -43,7 +43,9 @@ function touchHandler (ev) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('touchstart', touchHandler, true)
|
export const init = (_svgCanvas) => {
|
||||||
document.addEventListener('touchmove', touchHandler, true)
|
document.addEventListener('touchstart', touchHandler, true)
|
||||||
document.addEventListener('touchend', touchHandler, true)
|
document.addEventListener('touchmove', touchHandler, true)
|
||||||
document.addEventListener('touchcancel', touchHandler, true)
|
document.addEventListener('touchend', touchHandler, true)
|
||||||
|
document.addEventListener('touchcancel', touchHandler, true)
|
||||||
|
}
|
Loading…
Reference in New Issue