digirati-annotation-bridge
Advanced tools
Comparing version 0.2.15-alpha.be61f365 to 0.2.15-alpha.cba8b036
@@ -5,20 +5,12 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
import AnnotationBody from './annotationBody'; | ||
import { AnnotationSelector } from 'digirati-annotation-redux/es/lib/elucidate/index'; | ||
var W3C_SELECTOR = /[#&\?]xywh\=(pixel\:|percent\:)?(\d+),(\d+),(\d+),(\d+)/; | ||
export function parseTarget(source) { | ||
/** | ||
* @deprecated | ||
*/ | ||
export function parseTarget(target) { | ||
var scale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; | ||
var match = W3C_SELECTOR.exec(source); | ||
if (match) { | ||
return { | ||
unit: match[1] === 'percent:' ? 'percent' : 'pixel', | ||
scale: scale, | ||
x: parseInt(match[2], 10) * scale, | ||
y: parseInt(match[3], 10) * scale, | ||
width: parseInt(match[4], 10) * scale, | ||
height: parseInt(match[5], 10) * scale | ||
}; | ||
} | ||
return source; | ||
console.info('source to target =>', target.source, AnnotationSelector.parse(target, scale), AnnotationSelector.parseTarget(target.source, scale, target)); | ||
return AnnotationSelector.parseTarget(target.source, scale, target); | ||
} | ||
@@ -25,0 +17,0 @@ |
@@ -25,21 +25,14 @@ 'use strict'; | ||
var _index = require('digirati-annotation-redux/es/lib/elucidate/index'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var W3C_SELECTOR = /[#&\?]xywh\=(pixel\:|percent\:)?(\d+),(\d+),(\d+),(\d+)/; | ||
function parseTarget(source) { | ||
/** | ||
* @deprecated | ||
*/ | ||
function parseTarget(target) { | ||
var scale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; | ||
var match = W3C_SELECTOR.exec(source); | ||
if (match) { | ||
return { | ||
unit: match[1] === 'percent:' ? 'percent' : 'pixel', | ||
scale: scale, | ||
x: parseInt(match[2], 10) * scale, | ||
y: parseInt(match[3], 10) * scale, | ||
width: parseInt(match[4], 10) * scale, | ||
height: parseInt(match[5], 10) * scale | ||
}; | ||
} | ||
return source; | ||
console.info('source to target =>', target.source, _index.AnnotationSelector.parse(target, scale), _index.AnnotationSelector.parseTarget(target.source, scale, target)); | ||
return _index.AnnotationSelector.parseTarget(target.source, scale, target); | ||
} | ||
@@ -46,0 +39,0 @@ |
{ | ||
"name": "digirati-annotation-bridge", | ||
"version": "0.2.15-alpha.be61f365", | ||
"version": "0.2.15-alpha.cba8b036", | ||
"description": "Describe annotation-bridge here", | ||
@@ -21,3 +21,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"digirati-annotation-redux": "^0.2.15-alpha.be61f365" | ||
"digirati-annotation-redux": "^0.2.15-alpha.cba8b036" | ||
}, | ||
@@ -24,0 +24,0 @@ "devDependencies": { |
31571
728