@@ -16,7 +16,7 @@ var ClassView = function (parent, container) {
16
16
17
17
this . PAPER_SCALE = 1 ;
18
18
this . MIN_PAPER_SCALE = 0.2 ;
19
- this . MAX_PAPER_SCALE = 5 ;
19
+ this . MAX_PAPER_SCALE = 4 ;
20
20
21
21
this . init ( ) ;
22
22
@@ -244,21 +244,23 @@ ClassView.prototype.updateSizes = function () {
244
244
ClassView . prototype . zoom = function ( delta ) {
245
245
246
246
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 ;
247
252
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 ; }
255
258
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 ) ;
257
261
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
262
264
) ;
263
265
264
266
} ;
@@ -282,6 +284,8 @@ ClassView.prototype.init = function () {
282
284
}
283
285
} ) ;
284
286
287
+ setTimeout ( function ( ) { self . paper . setOrigin ( 0 , 0 ) } , 100 ) ;
288
+
285
289
// enables links re-routing when dragging objects
286
290
this . graph . on ( "change:position" , function ( object ) {
287
291
if ( _ . contains ( self . objects , object ) )
0 commit comments