@@ -16,7 +16,7 @@ var ClassView = function (parent, container) {
1616
1717 this . PAPER_SCALE = 1 ;
1818 this . MIN_PAPER_SCALE = 0.2 ;
19- this . MAX_PAPER_SCALE = 5 ;
19+ this . MAX_PAPER_SCALE = 4 ;
2020
2121 this . init ( ) ;
2222
@@ -244,21 +244,23 @@ ClassView.prototype.updateSizes = function () {
244244ClassView . prototype . zoom = function ( delta ) {
245245
246246 var scaleOld = this . PAPER_SCALE , scaleDelta ;
247+ var sw = this . cacheUMLExplorer . elements . classViewContainer . offsetWidth ,
248+ sh = this . cacheUMLExplorer . elements . classViewContainer . offsetHeight ,
249+ side = delta > 0 ? 1 : - 1 ,
250+ ox = this . paper . options . origin . x ,
251+ oy = this . paper . options . origin . y ;
247252 if ( typeof delta === "number" ) {
248- this . PAPER_SCALE += delta * Math . min (
249- 0.5 ,
250- Math . abs ( this . PAPER_SCALE - ( delta < 0 ? this . MIN_PAPER_SCALE : this . MAX_PAPER_SCALE ) ) / 2
251- ) ;
252- } else {
253- this . PAPER_SCALE = 1 ;
254- }
253+ this . PAPER_SCALE += delta * Math . min (
254+ 0.3 ,
255+ Math . abs ( this . PAPER_SCALE - ( delta < 0 ? this . MIN_PAPER_SCALE : this . MAX_PAPER_SCALE ) ) / 2
256+ ) ;
257+ } else { this . PAPER_SCALE = 1 ; }
255258 this . paper . scale ( this . PAPER_SCALE , this . PAPER_SCALE ) ;
256- scaleDelta = this . PAPER_SCALE - scaleOld ;
259+ scaleDelta = side *
260+ ( side > 0 ? this . PAPER_SCALE / scaleOld - 1 : ( scaleOld - this . PAPER_SCALE ) / scaleOld ) ;
257261 this . paper . setOrigin (
258- this . paper . options . origin . x
259- - scaleDelta * this . cacheUMLExplorer . elements . classViewContainer . offsetWidth / 2 ,
260- this . paper . options . origin . y
261- - scaleDelta * this . cacheUMLExplorer . elements . classViewContainer . offsetHeight / 2
262+ ox - ( sw / 2 - ox ) * scaleDelta ,
263+ oy - ( sh / 2 - oy ) * scaleDelta
262264 ) ;
263265
264266} ;
@@ -282,6 +284,8 @@ ClassView.prototype.init = function () {
282284 }
283285 } ) ;
284286
287+ setTimeout ( function ( ) { self . paper . setOrigin ( 0 , 0 ) } , 100 ) ;
288+
285289 // enables links re-routing when dragging objects
286290 this . graph . on ( "change:position" , function ( object ) {
287291 if ( _ . contains ( self . objects , object ) )
0 commit comments