Skip to content

Commit 94873df

Browse files
committedMar 15, 2017
Build and bump
1 parent 1be71ca commit 94873df

File tree

5 files changed

+31
-13
lines changed

5 files changed

+31
-13
lines changed
 

‎bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svg-pan-zoom",
3-
"version": "3.4.1",
3+
"version": "3.5.0",
44
"homepage": "https://github.com/ariutta/svg-pan-zoom",
55
"authors": [
66
"Andrea Leofreddi <a.leofreddi@itcharm.com>",

‎dist/svg-pan-zoom.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Type definitions for svg-pan-zoom v3.4.1
1+
// Type definitions for svg-pan-zoom v3.5.0
22
// Project: https://github.com/ariutta/svg-pan-zoom
33
// Definitions by: César Vidril <https://github.com/Yimiprod>
44
// Definitions: https://github.com/ariutta/svg-pan-zoom

‎dist/svg-pan-zoom.js

+26-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// svg-pan-zoom v3.4.1
1+
// svg-pan-zoom v3.5.0
22
// https://github.com/ariutta/svg-pan-zoom
33
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
44
var svgPanZoom = require('./svg-pan-zoom.js');
@@ -371,6 +371,9 @@ ShadowViewport.prototype.setCTM = function(newCTM) {
371371
if (this.options.beforeZoom(this.getRelativeZoom(), this.computeRelativeZoom(newCTM.a)) === false) {
372372
newCTM.a = newCTM.d = this.activeState.zoom
373373
willZoom = false
374+
} else {
375+
this.updateCache(newCTM);
376+
this.options.onZoom(this.getRelativeZoom())
374377
}
375378
}
376379

@@ -413,18 +416,15 @@ ShadowViewport.prototype.setCTM = function(newCTM) {
413416
// Update willPan flag
414417
if (preventPanX && preventPanY) {
415418
willPan = false
419+
} else {
420+
this.updateCache(newCTM);
421+
this.options.onPan(this.getPan());
416422
}
417423
}
418424

419425
// Check again if should zoom or pan
420426
if (willZoom || willPan) {
421-
this.updateCache(newCTM)
422-
423427
this.updateCTMOnNextFrame()
424-
425-
// After callbacks
426-
if (willZoom) {this.options.onZoom(this.getRelativeZoom())}
427-
if (willPan) {this.options.onPan(this.getPan())}
428428
}
429429
}
430430
}
@@ -468,11 +468,18 @@ ShadowViewport.prototype.updateCTMOnNextFrame = function() {
468468
* Update viewport CTM with cached CTM
469469
*/
470470
ShadowViewport.prototype.updateCTM = function() {
471+
var ctm = this.getCTM()
472+
471473
// Updates SVG element
472-
SvgUtils.setCTM(this.viewport, this.getCTM(), this.defs)
474+
SvgUtils.setCTM(this.viewport, ctm, this.defs)
473475

474476
// Free the lock
475477
this.pendingUpdate = false
478+
479+
// Notify about the update
480+
if(this.options.onUpdatedCTM) {
481+
this.options.onUpdatedCTM(ctm)
482+
}
476483
}
477484

478485
module.exports = function(viewport, options){
@@ -511,6 +518,7 @@ var optionsDefaults = {
511518
, onPan: null
512519
, customEventsHandler: null
513520
, eventsListenerElement: null
521+
, onUpdatedCTM: null
514522
}
515523

516524
SvgPanZoom.prototype.init = function(svg, options) {
@@ -555,6 +563,9 @@ SvgPanZoom.prototype.init = function(svg, options) {
555563
, onPan: function(point) {
556564
if (that.viewport && that.options.onPan) {return that.options.onPan(point)}
557565
}
566+
, onUpdatedCTM: function(ctm) {
567+
if (that.viewport && that.options.onUpdatedCTM) {return that.options.onUpdatedCTM(ctm)}
568+
}
558569
})
559570

560571
// Wrap callbacks into public API context
@@ -563,6 +574,7 @@ SvgPanZoom.prototype.init = function(svg, options) {
563574
publicInstance.setOnZoom(this.options.onZoom)
564575
publicInstance.setBeforePan(this.options.beforePan)
565576
publicInstance.setOnPan(this.options.onPan)
577+
publicInstance.setOnUpdatedCTM(this.options.onUpdatedCTM)
566578

567579
if (this.options.controlIconsEnabled) {
568580
ControlIcons.enable(this)
@@ -1075,6 +1087,7 @@ SvgPanZoom.prototype.destroy = function() {
10751087
this.onZoom = null
10761088
this.beforePan = null
10771089
this.onPan = null
1090+
this.onUpdatedCTM = null
10781091

10791092
// Destroy custom event handlers
10801093
if (this.options.customEventsHandler != null) { // jshint ignore:line
@@ -1108,6 +1121,9 @@ SvgPanZoom.prototype.destroy = function() {
11081121
// Delete options and its contents
11091122
delete this.options
11101123

1124+
// Delete viewport to make public shadow viewport functions uncallable
1125+
delete this.viewport
1126+
11111127
// Destroy public instance and rewrite getPublicInstance
11121128
delete this.publicInstance
11131129
delete this.pi
@@ -1179,6 +1195,8 @@ SvgPanZoom.prototype.getPublicInstance = function() {
11791195
, zoomIn: function() {this.zoomBy(1 + that.options.zoomScaleSensitivity); return that.pi}
11801196
, zoomOut: function() {this.zoomBy(1 / (1 + that.options.zoomScaleSensitivity)); return that.pi}
11811197
, getZoom: function() {return that.getRelativeZoom()}
1198+
// CTM update
1199+
, setOnUpdatedCTM: function(fn) {that.options.onUpdatedCTM = fn === null ? null : Utils.proxy(fn, that.publicInstance); return that.pi}
11821200
// Reset
11831201
, resetZoom: function() {that.resetZoom(); return that.pi}
11841202
, resetPan: function() {that.resetPan(); return that.pi}

‎dist/svg-pan-zoom.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svg-pan-zoom",
3-
"version": "3.4.1",
3+
"version": "3.5.0",
44
"main": "dist/svg-pan-zoom.js",
55
"types": "dist/svg-pan-zoom.d.ts",
66
"browser": "src/browserify.js",

0 commit comments

Comments
 (0)
Please sign in to comment.