Skip to content

Commit f899f74

Browse files
committed
minor
1 parent fbab5e9 commit f899f74

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

spherical.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@
6464
_container.style.webkitPerspective = _container.style.perspective = _cubeZ + 'px';
6565
};
6666

67+
/**
68+
* sets the z value based on the container size
69+
* @public
70+
*/
71+
this.resetZ = function() {
72+
_cubeZ = (Math.sqrt(_container.clientWidth * _container.clientHeight) / 2.5);
73+
74+
_updateCubeTransform();
75+
_updatePerspective();
76+
};
77+
6778
/**
6879
* clamps and sets the z value
6980
* @param {number} z
@@ -78,7 +89,7 @@
7889
* calculates the z value
7990
* @param {number} amt
8091
*/
81-
var _increaseZoom = function(amt) {
92+
var _adjustZoom = function(amt) {
8293
amt /= 15;
8394
amt = ((0.2 * _cubeZ) - 8.2) * amt;
8495

@@ -94,7 +105,7 @@
94105
var _onScroll = function(ev) {
95106
ev.preventDefault();
96107
var delta = Math.max(-1, Math.min(1, (ev.wheelDelta || -ev.deltaY)));
97-
_increaseZoom(delta * 15);
108+
_adjustZoom(delta * 15);
98109
};
99110

100111
_container.addEventListener('wheel', _onScroll);
@@ -103,7 +114,7 @@
103114
if (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
104115
var _lastScale = 1;
105116
var _onGestureChange = function(ev) {
106-
_increaseZoom((ev.scale - _lastScale) * 50);
117+
_adjustZoom((ev.scale - _lastScale) * 50);
107118
_lastScale = ev.scale;
108119
};
109120
document.body.addEventListener('gesturestart', function(e) {
@@ -182,16 +193,6 @@
182193
}
183194
}.bind(this);
184195

185-
/**
186-
* sets the z value based on the container size
187-
* @public
188-
*/
189-
this.resetZ = function() {
190-
_cubeZ = (Math.sqrt(_container.clientWidth * _container.clientHeight) / 2.5);
191-
192-
_updateCubeTransform();
193-
_updatePerspective();
194-
};
195196

196197

197198
(function init() {

0 commit comments

Comments
 (0)