first commit
This commit is contained in:
commit
eb2f504652
32490 changed files with 5731109 additions and 0 deletions
52
node_modules/panzoom/lib/domController.js
generated
vendored
Normal file
52
node_modules/panzoom/lib/domController.js
generated
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
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');
|
||||
}
|
||||
|
||||
var owner = domElement.parentElement;
|
||||
domElement.scrollTop = 0;
|
||||
|
||||
if (!options.disableKeyboardInteraction) {
|
||||
owner.setAttribute('tabindex', 0);
|
||||
}
|
||||
|
||||
var api = {
|
||||
getBBox: getBBox,
|
||||
getOwner: getOwner,
|
||||
applyTransform: applyTransform,
|
||||
};
|
||||
|
||||
return api;
|
||||
|
||||
function getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
function getBBox() {
|
||||
// TODO: We should probably cache this?
|
||||
return {
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: domElement.clientWidth,
|
||||
height: domElement.clientHeight
|
||||
};
|
||||
}
|
||||
|
||||
function applyTransform(transform) {
|
||||
// TODO: Should we cache this?
|
||||
domElement.style.transformOrigin = '0 0 0';
|
||||
domElement.style.transform = 'matrix(' +
|
||||
transform.scale + ', 0, 0, ' +
|
||||
transform.scale + ', ' +
|
||||
transform.x + ', ' + transform.y + ')';
|
||||
}
|
||||
}
|
||||
|
||||
function isDomElement(element) {
|
||||
return element && element.parentElement && element.style;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue