Skip to content
This repository has been archived by the owner on Mar 27, 2019. It is now read-only.

Fix division by zero in _wheelZoom #986

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/iscroll-infinite.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! iScroll v5.1.3 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
/*! iScroll v5.1.3 ~ (c) 2008-2015 Matteo Spinelli ~ http://cubiq.org/license */
(function (window, document, Math) {
var rAF = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
Expand Down
2 changes: 1 addition & 1 deletion build/iscroll-lite.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! iScroll v5.1.3 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
/*! iScroll v5.1.3 ~ (c) 2008-2015 Matteo Spinelli ~ http://cubiq.org/license */
(function (window, document, Math) {
var rAF = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
Expand Down
2 changes: 1 addition & 1 deletion build/iscroll-probe.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! iScroll v5.1.3 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
/*! iScroll v5.1.3 ~ (c) 2008-2015 Matteo Spinelli ~ http://cubiq.org/license */
(function (window, document, Math) {
var rAF = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
Expand Down
16 changes: 9 additions & 7 deletions build/iscroll-zoom.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! iScroll v5.1.3 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
/*! iScroll v5.1.3 ~ (c) 2008-2015 Matteo Spinelli ~ http://cubiq.org/license */
(function (window, document, Math) {
var rAF = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
Expand Down Expand Up @@ -1164,8 +1164,9 @@ IScroll.prototype = {
},

_wheelZoom: function (e) {
var wheelDeltaY,
var deltaY,
deltaScale,
sign,
that = this;

// Execute the zoomEnd event after 400ms the wheel stopped scrolling
Expand All @@ -1175,18 +1176,19 @@ IScroll.prototype = {
}, 400);

if ( 'deltaX' in e ) {
wheelDeltaY = -e.deltaY / Math.abs(e.deltaY);
deltaY = -e.deltaY;
} else if ('wheelDeltaX' in e) {
wheelDeltaY = e.wheelDeltaY / Math.abs(e.wheelDeltaY);
deltaY = e.wheelDeltaY;
} else if('wheelDelta' in e) {
wheelDeltaY = e.wheelDelta / Math.abs(e.wheelDelta);
deltaY = e.wheelDelta;
} else if ('detail' in e) {
wheelDeltaY = -e.detail / Math.abs(e.wheelDelta);
deltaY = -e.detail;
} else {
return;
}

deltaScale = this.scale + wheelDeltaY / 5;
sign = deltaY ? deltaY < 0 ? -1 : 1 : 0;
deltaScale = this.scale + sign * 1/5;

this.zoom(deltaScale, e.pageX, e.pageY, 0);
},
Expand Down
2 changes: 1 addition & 1 deletion build/iscroll.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! iScroll v5.1.3 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
/*! iScroll v5.1.3 ~ (c) 2008-2015 Matteo Spinelli ~ http://cubiq.org/license */
(function (window, document, Math) {
var rAF = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
Expand Down
14 changes: 8 additions & 6 deletions src/zoom/zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@
},

_wheelZoom: function (e) {
var wheelDeltaY,
var deltaY,
deltaScale,
sign,
that = this;

// Execute the zoomEnd event after 400ms the wheel stopped scrolling
Expand All @@ -153,18 +154,19 @@
}, 400);

if ( 'deltaX' in e ) {
wheelDeltaY = -e.deltaY / Math.abs(e.deltaY);
deltaY = -e.deltaY;
} else if ('wheelDeltaX' in e) {
wheelDeltaY = e.wheelDeltaY / Math.abs(e.wheelDeltaY);
deltaY = e.wheelDeltaY;
} else if('wheelDelta' in e) {
wheelDeltaY = e.wheelDelta / Math.abs(e.wheelDelta);
deltaY = e.wheelDelta;
} else if ('detail' in e) {
wheelDeltaY = -e.detail / Math.abs(e.wheelDelta);
deltaY = -e.detail;
} else {
return;
}

deltaScale = this.scale + wheelDeltaY / 5;
sign = deltaY ? deltaY < 0 ? -1 : 1 : 0;
deltaScale = this.scale + sign * 1/5;

this.zoom(deltaScale, e.pageX, e.pageY, 0);
},