Skip to content

Commit

Permalink
#152 - clamp mouse wheel delta to +/- 1 so we don't zoom too fast
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanttb committed Sep 14, 2015
1 parent 0aa4542 commit 5766158
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions js/jquery.geo.geomap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2368,19 +2368,14 @@
}

if (e.deltaY !== 0) {
var tiledFull = Math.abs( e.deltaY ) >= 1;
this._clearInteractiveTimeout( );

if ( e.deltaY > 0 ) {
e.deltaY = Math.ceil( e.deltaY );
} else {
e.deltaY = Math.floor( e.deltaY );
}
var delta = e.deltaY > 0 ? 1 : -1;

var offset = $(e.currentTarget).offset();
this._anchor = [e.pageX - offset.left, e.pageY - offset.top];

var wheelCenterAndSize = this._getZoomCenterAndSize( this._anchor, e.deltaY, this._options[ "tilingScheme" ] !== null ? tiledFull : false );
var wheelCenterAndSize = this._getZoomCenterAndSize( this._anchor, delta, this._options[ "tilingScheme" ] !== null );

this._setInteractiveCenterAndSize( wheelCenterAndSize.center, wheelCenterAndSize.pixelSize );
this._interactiveTransform( );
Expand Down
2 changes: 1 addition & 1 deletion test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
// create a map
var map = $("#map").geomap({
center: [ -71.3595678, 42.3604823 ],
zoom: 8,
zoom: 6,
});
});
</script>
Expand Down

0 comments on commit 5766158

Please sign in to comment.