Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"env": {
"browser": true,
"node": true,
"es6": true
},
"rules": {
"semi": "error",
"no-undef": "error",
"no-unused-vars": "error",
"no-shadow": "error"
}
}
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ function createPanZoom(domElement, options) {
}

function smoothMoveTo(x, y){
internalMoveBy(x - transform.x, y - transform.y, true)
internalMoveBy(x - transform.x, y - transform.y, true);
}

function internalMoveBy(dx, dy, smooth) {
Expand Down Expand Up @@ -1023,8 +1023,8 @@ function autoRun() {
function collectOptions(script) {
var attrs = script.attributes;
var options = {};
for (var i = 0; i < attrs.length; ++i) {
var attr = attrs[i];
for (var j = 0; j < attrs.length; ++j) {
var attr = attrs[j];
var nameValue = getPanzoomAttributeNameValue(attr);
if (nameValue) {
options[nameValue.name] = nameValue.value;
Expand Down
14 changes: 7 additions & 7 deletions lib/domController.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module.exports = makeDomController
module.exports = makeDomController;

module.exports.canAttach = isDomElement;

function makeDomController(domElement, options) {
var elementValid = isDomElement(domElement);
if (!elementValid) {
throw new Error('panzoom requires DOM element to be attached to the DOM tree')
throw new Error('panzoom requires DOM element to be attached to the DOM tree');
}

var owner = domElement.parentElement;
Expand All @@ -19,12 +19,12 @@ function makeDomController(domElement, options) {
getBBox: getBBox,
getOwner: getOwner,
applyTransform: applyTransform,
}
};

return api
return api;

function getOwner() {
return owner
return owner;
}

function getBBox() {
Expand All @@ -34,7 +34,7 @@ function makeDomController(domElement, options) {
top: 0,
width: domElement.clientWidth,
height: domElement.clientHeight
}
};
}

function applyTransform(transform) {
Expand All @@ -43,7 +43,7 @@ function makeDomController(domElement, options) {
domElement.style.transform = 'matrix(' +
transform.scale + ', 0, 0, ' +
transform.scale + ', ' +
transform.x + ', ' + transform.y + ')'
transform.x + ', ' + transform.y + ')';
}
}

Expand Down
14 changes: 7 additions & 7 deletions lib/getSvgTransformMatrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* Returns transformation matrix for an element. If no such transformation matrix
* exist - a new one is created.
*/
module.exports = getSvgTransformMatrix
module.exports = getSvgTransformMatrix;

function getSvgTransformMatrix(svgElement) {
var baseVal = svgElement.transform.baseVal
if (baseVal.numberOfItems) return baseVal.getItem(0)
var baseVal = svgElement.transform.baseVal;
if (baseVal.numberOfItems) return baseVal.getItem(0);

var owner = svgElement.ownerSVGElement || svgElement
var transform = owner.createSVGTransform()
svgElement.transform.baseVal.appendItem(transform)
var owner = svgElement.ownerSVGElement || svgElement;
var transform = owner.createSVGTransform();
svgElement.transform.baseVal.appendItem(transform);

return transform
return transform;
}
2 changes: 1 addition & 1 deletion lib/kinetic.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,5 @@ function getRequestAnimationFrame() {

return function (handler) {
return setTimeout(handler, 16);
}
};
}
24 changes: 12 additions & 12 deletions lib/svgController.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module.exports = makeSvgController
module.exports = makeSvgController;
module.exports.canAttach = isSVGElement;

function makeSvgController(svgElement, options) {
if (!isSVGElement(svgElement)) {
throw new Error('svg element is required for svg.panzoom to work')
throw new Error('svg element is required for svg.panzoom to work');
}

var owner = svgElement.ownerSVGElement
var owner = svgElement.ownerSVGElement;
if (!owner) {
throw new Error(
'Do not apply panzoom to the root <svg> element. ' +
'Use its child instead (e.g. <g></g>). ' +
'As of March 2016 only FireFox supported transform on the root element')
'As of March 2016 only FireFox supported transform on the root element');
}

if (!options.disableKeyboardInteraction) {
Expand All @@ -24,22 +24,22 @@ function makeSvgController(svgElement, options) {
getOwner: getOwner,
applyTransform: applyTransform,
initTransform: initTransform
}
};

return api
return api;

function getOwner() {
return owner
return owner;
}

function getBBox() {
var bbox = svgElement.getBBox()
var bbox = svgElement.getBBox();
return {
left: bbox.x,
top: bbox.y,
width: bbox.width,
height: bbox.height,
}
};
}

function getScreenCTM() {
Expand All @@ -53,11 +53,11 @@ function makeSvgController(svgElement, options) {
}

function initTransform(transform) {
var screenCTM = svgElement.getCTM()
var screenCTM = svgElement.getCTM();

// The above line returns null on Firefox
if (screenCTM === null) {
screenCTM = document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGMatrix()
screenCTM = document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGMatrix();
}

transform.x = screenCTM.e;
Expand All @@ -70,7 +70,7 @@ function makeSvgController(svgElement, options) {
svgElement.setAttribute('transform', 'matrix(' +
transform.scale + ' 0 0 ' +
transform.scale + ' ' +
transform.x + ' ' + transform.y + ')')
transform.x + ' ' + transform.y + ')');
}
}

Expand Down
Loading