Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to api to expose mouse move on panning #167

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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: 16 additions & 2 deletions dist/panzoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ function createPanZoom(domElement, options) {
var mouseX;
var mouseY;

//save mouse delta
var mouseChange = {};

var pinchZoomLength;

var smoothScroll;
Expand Down Expand Up @@ -135,7 +138,9 @@ function createPanZoom(domElement, options) {
setTransformOrigin: setTransformOrigin,

getZoomSpeed: getZoomSpeed,
setZoomSpeed: setZoomSpeed
setZoomSpeed: setZoomSpeed,

getMouseMovement: getMouseMovement
};

eventify(api);
Expand Down Expand Up @@ -251,6 +256,10 @@ function createPanZoom(domElement, options) {
return speed;
}

function getMouseMovement(){
return mouseChange;
}

function setZoomSpeed(newSpeed) {
if (!Number.isFinite(newSpeed)) {
throw new Error('Zoom speed should be a number');
Expand All @@ -276,6 +285,10 @@ function createPanZoom(domElement, options) {
}

function moveBy(dx, dy) {
// save dx,dy to later be exposed through the through the api
// allows user to track mouse movements on panning
mouseChange.dx = dx;
mouseChange.dy = dy;
moveTo(transform.x + dx, transform.y + dy);
}

Expand Down Expand Up @@ -885,6 +898,7 @@ function createPanZoom(domElement, options) {
function triggerEvent(name) {
api.fire(name, api);
}

}

function parseTransformOrigin(options) {
Expand Down Expand Up @@ -1614,7 +1628,7 @@ module.exports = function bezier (mX1, mY1, mX2, mY2) {
};

},{}],9:[function(require,module,exports){
module.exports = function(subject) {
module.exports = function eventify(subject) {
validateSubject(subject);

var eventsStorage = createEventsStorage(subject);
Expand Down
2 changes: 1 addition & 1 deletion dist/panzoom.min.js

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ function createPanZoom(domElement, options) {
var mouseX;
var mouseY;

//save mouse delta
var mouseChange = {};

var pinchZoomLength;

var smoothScroll;
Expand Down Expand Up @@ -134,7 +137,9 @@ function createPanZoom(domElement, options) {
setTransformOrigin: setTransformOrigin,

getZoomSpeed: getZoomSpeed,
setZoomSpeed: setZoomSpeed
setZoomSpeed: setZoomSpeed,

getMouseMovement: getMouseMovement
};

eventify(api);
Expand Down Expand Up @@ -250,6 +255,10 @@ function createPanZoom(domElement, options) {
return speed;
}

function getMouseMovement(){
return mouseChange;
}

function setZoomSpeed(newSpeed) {
if (!Number.isFinite(newSpeed)) {
throw new Error('Zoom speed should be a number');
Expand All @@ -275,6 +284,10 @@ function createPanZoom(domElement, options) {
}

function moveBy(dx, dy) {
// save dx,dy to later be exposed through the through the api
// allows user to track mouse movements on panning
mouseChange.dx = dx;
mouseChange.dy = dy;
moveTo(transform.x + dx, transform.y + dy);
}

Expand Down Expand Up @@ -884,6 +897,7 @@ function createPanZoom(domElement, options) {
function triggerEvent(name) {
api.fire(name, api);
}

}

function parseTransformOrigin(options) {
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"dependencies": {
"amator": "^1.1.0",
"ngraph.events": "^1.0.0",
"ngraph.events": "^1.2.0",
"wheel": "^1.0.0"
},
"devDependencies": {
Expand Down