12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import {
- append as svgAppend,
- attr as svgAttr,
- create as svgCreate
- } from 'tiny-svg';
- export default function TouchFix(canvas, eventBus) {
- var self = this;
- eventBus.on('canvas.init', function(e) {
- self.addBBoxMarker(e.svg);
- });
- }
- TouchFix.$inject = [ 'canvas', 'eventBus' ];
- /**
- * Safari mobile (iOS 7) does not fire touchstart event in <SVG> element
- * if there is no shape between 0,0 and viewport elements origin.
- *
- * So touchstart event is only fired when the <g class="viewport"> element was hit.
- * Putting an element over and below the 'viewport' fixes that behavior.
- */
- TouchFix.prototype.addBBoxMarker = function(svg) {
- var markerStyle = {
- fill: 'none',
- class: 'outer-bound-marker'
- };
- var rect1 = svgCreate('rect');
- svgAttr(rect1, {
- x: -10000,
- y: 10000,
- width: 10,
- height: 10
- });
- svgAttr(rect1, markerStyle);
- svgAppend(svg, rect1);
- var rect2 = svgCreate('rect');
- svgAttr(rect2, {
- x: 10000,
- y: 10000,
- width: 10,
- height: 10
- });
- svgAttr(rect2, markerStyle);
- svgAppend(svg, rect2);
- };
|