From 7bc54e15175a68c1d51caa97bf0ef76786a1a86e Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Mon, 21 May 2012 15:08:31 +0200 Subject: [PATCH 01/17] Don't round wheel change zoom for maps with fractional zoom --- lib/OpenLayers/Control/Navigation.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Control/Navigation.js b/lib/OpenLayers/Control/Navigation.js index 11f1a05845..17d2bf0aaa 100644 --- a/lib/OpenLayers/Control/Navigation.js +++ b/lib/OpenLayers/Control/Navigation.js @@ -261,8 +261,11 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, { * deltaZ - {Integer} */ wheelChange: function(evt, deltaZ) { + if (!this.map.fractionalZoom) { + deltaZ = Math.round(deltaZ); + } var currentZoom = this.map.getZoom(); - var newZoom = this.map.getZoom() + Math.round(deltaZ); + var newZoom = this.map.getZoom() + deltaZ; newZoom = Math.max(newZoom, 0); newZoom = Math.min(newZoom, this.map.getNumZoomLevels()); if (newZoom === currentZoom) { From 95bc51ce3d8d39d83ae3ee9fd5eadb5e5c3acf8f Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Mon, 21 May 2012 15:11:05 +0200 Subject: [PATCH 02/17] Make analog mouse wheel adjustments configurable and reduce sensitivity --- lib/OpenLayers/Handler/MouseWheel.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Handler/MouseWheel.js b/lib/OpenLayers/Handler/MouseWheel.js index e75ce0a415..0228c0b74c 100644 --- a/lib/OpenLayers/Handler/MouseWheel.js +++ b/lib/OpenLayers/Handler/MouseWheel.js @@ -54,6 +54,12 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, { * negative) */ cumulative: true, + + /** + * Property: analogWheelPrecision + * {Integer} Adjust to get analog scroll wheel to feel right + */ + analogWheelPrecision: 360, /** * Constructor: OpenLayers.Handler.MouseWheel @@ -170,7 +176,7 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, { e = window.event; } if (e.wheelDelta) { - delta = e.wheelDelta/120; + delta = e.wheelDelta/this.analogWheelPrecision; if (window.opera && window.opera.version() < 9.2) { delta = -delta; } From f377d0387f12b4a485a44ae411f339486f2ccc36 Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Tue, 22 May 2012 17:29:12 +0200 Subject: [PATCH 03/17] Adjusted delta in MouseWheel test --- tests/Handler/MouseWheel.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Handler/MouseWheel.html b/tests/Handler/MouseWheel.html index d41c2cd18c..1d2a6b7eb5 100644 --- a/tests/Handler/MouseWheel.html +++ b/tests/Handler/MouseWheel.html @@ -107,7 +107,7 @@ var activated = handler.activate(); - var delta = 120; + var delta = 360; if (window.opera && window.opera.version() < 9.2) delta = -delta; handler.onWheelEvent({'target':map.layers[0].div, wheelDelta: delta}); handler.onWheelEvent({'target':map.layers[0].div, wheelDelta: delta}); From 12931612eabb56ab76dd63c8c7cb5a9584bb38cc Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Tue, 22 May 2012 17:43:52 +0200 Subject: [PATCH 04/17] Don't affect digital mouse wheels (a.k.a. step-scroll) --- lib/OpenLayers/Handler/MouseWheel.js | 7 ++++++- tests/Handler/MouseWheel.html | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Handler/MouseWheel.js b/lib/OpenLayers/Handler/MouseWheel.js index 0228c0b74c..7cfc40cfce 100644 --- a/lib/OpenLayers/Handler/MouseWheel.js +++ b/lib/OpenLayers/Handler/MouseWheel.js @@ -176,7 +176,12 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, { e = window.event; } if (e.wheelDelta) { - delta = e.wheelDelta/this.analogWheelPrecision; + delta = e.wheelDelta; + if (delta % 120 === 0) { + delta = delta / 120; + } else { + delta = delta / this.analogWheelPrecision; + } if (window.opera && window.opera.version() < 9.2) { delta = -delta; } diff --git a/tests/Handler/MouseWheel.html b/tests/Handler/MouseWheel.html index 1d2a6b7eb5..d41c2cd18c 100644 --- a/tests/Handler/MouseWheel.html +++ b/tests/Handler/MouseWheel.html @@ -107,7 +107,7 @@ var activated = handler.activate(); - var delta = 360; + var delta = 120; if (window.opera && window.opera.version() < 9.2) delta = -delta; handler.onWheelEvent({'target':map.layers[0].div, wheelDelta: delta}); handler.onWheelEvent({'target':map.layers[0].div, wheelDelta: delta}); From a1dff8ad9bf42e1397c95746dc9f7696eab64cbd Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Tue, 29 May 2012 13:23:40 +0200 Subject: [PATCH 05/17] Changed OpenLayers.BROWSER_NAME to be 'chrome' for Google Chrome instead of 'safari'. Added OpenLayers.IS_WEBKIT and changed tests where necessary. --- lib/OpenLayers/Util.js | 13 ++++++++++++- tests/deprecated/Layer/MapServer.html | 4 ++-- tests/deprecated/Layer/WMS.html | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index ac598f2604..18ebe0a420 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -1439,13 +1439,22 @@ OpenLayers.Util.removeTail = function(url) { return head; }; +/** + * Constant: IS_WEBKIT + * {Boolean} True if the userAgent reports the browser to use the WebKit engine + */ +OpenLayers.IS_WEBKIT = (function() { + var ua = navigator.userAgent.toLowerCase(); + return ua.indexOf("webkit") !== -1; +})(); + /** * Constant: IS_GECKO * {Boolean} True if the userAgent reports the browser to use the Gecko engine */ OpenLayers.IS_GECKO = (function() { var ua = navigator.userAgent.toLowerCase(); - return ua.indexOf("webkit") == -1 && ua.indexOf("gecko") != -1; + return !OpenLayers.IS_WEBKIT && ua.indexOf("gecko") !== -1; })(); /** @@ -1475,6 +1484,8 @@ OpenLayers.BROWSER_NAME = (function() { name = "opera"; } else if (ua.indexOf("msie") != -1) { name = "msie"; + } else if(ua.indexOf("chrome") != -1) { + name = "chrome"; } else if (ua.indexOf("safari") != -1) { name = "safari"; } else if (ua.indexOf("mozilla") != -1) { diff --git a/tests/deprecated/Layer/MapServer.html b/tests/deprecated/Layer/MapServer.html index 27ce63dd20..ec6e7a5792 100644 --- a/tests/deprecated/Layer/MapServer.html +++ b/tests/deprecated/Layer/MapServer.html @@ -18,9 +18,9 @@ (window.location.host == "localhost") || (window.location.host == "openlayers.org"); - if (OpenLayers.BROWSER_NAME == "opera" || OpenLayers.BROWSER_NAME == "safari") { + if (OpenLayers.BROWSER_NAME == "opera" || OpenLayers.IS_WEBKIT) { t.plan(1); - t.debug_print("Can't test google reprojection in Opera or Safari."); + t.debug_print("Can't test google reprojection in Opera or WebKit."); } else if(validkey) { t.plan(5); var map = new OpenLayers.Map('map'); diff --git a/tests/deprecated/Layer/WMS.html b/tests/deprecated/Layer/WMS.html index 523d6eef12..cca85ffc83 100644 --- a/tests/deprecated/Layer/WMS.html +++ b/tests/deprecated/Layer/WMS.html @@ -16,7 +16,7 @@ var validkey = (window.location.protocol == "file:") || (window.location.host == "localhost") || (window.location.host == "openlayers.org"); - if (OpenLayers.BROWSER_NAME == "opera" || OpenLayers.BROWSER_NAME == "safari") { + if (OpenLayers.BROWSER_NAME == "opera" || OpenLayers.IS_WEBKIT) { t.plan(1); t.debug_print("Can't test google reprojection in Opera or Safari."); } else if(validkey) { From 50d24d775643f0b5f44fde50853e273975973030 Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Tue, 29 May 2012 13:26:27 +0200 Subject: [PATCH 06/17] Improve analog mouse wheel detection and normalize event.wheelDelta for Safari --- lib/OpenLayers/Handler/MouseWheel.js | 29 +++++++++++++++++++++------- tests/Handler/MouseWheel.html | 3 ++- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/lib/OpenLayers/Handler/MouseWheel.js b/lib/OpenLayers/Handler/MouseWheel.js index 7cfc40cfce..c21459a6cb 100644 --- a/lib/OpenLayers/Handler/MouseWheel.js +++ b/lib/OpenLayers/Handler/MouseWheel.js @@ -55,12 +55,19 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, { */ cumulative: true, + /** + * APIProperty: isAnalogScrollWheel + * {Boolean} Will switch to true when an event with analog scroll value + * is detected. + */ + isAnalogScrollWheel: false, + /** * Property: analogWheelPrecision * {Integer} Adjust to get analog scroll wheel to feel right */ analogWheelPrecision: 360, - + /** * Constructor: OpenLayers.Handler.MouseWheel * @@ -175,16 +182,24 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, { if (!e) { e = window.event; } + if (e.wheelDelta) { delta = e.wheelDelta; - if (delta % 120 === 0) { - delta = delta / 120; - } else { - delta = delta / this.analogWheelPrecision; - } - if (window.opera && window.opera.version() < 9.2) { + + if (OpenLayers.BROWSER_NAME === "safari" && !this.isAnalogScrollWheel) { + delta = delta * 10; + } else if (window.opera && window.opera.version() < 9.2) { delta = -delta; } + + this.isAnalogScrollWheel = (this.isAnalogScrollWheel || + delta % 40 !== 0 || Math.abs(delta) < 120); + + if (this.isAnalogScrollWheel) { + delta = delta / this.analogWheelPrecision; + } else { + delta = Math.round(delta / 120); + } } else if (e.detail) { delta = -e.detail / 3; } diff --git a/tests/Handler/MouseWheel.html b/tests/Handler/MouseWheel.html index d41c2cd18c..251a879e9c 100644 --- a/tests/Handler/MouseWheel.html +++ b/tests/Handler/MouseWheel.html @@ -108,7 +108,8 @@ var activated = handler.activate(); var delta = 120; - if (window.opera && window.opera.version() < 9.2) delta = -delta; + if (window.opera && window.opera.version() < 9.2) { delta = -delta; } + if (OpenLayers.BROWSER_NAME === "safari") delta = delta / 10; handler.onWheelEvent({'target':map.layers[0].div, wheelDelta: delta}); handler.onWheelEvent({'target':map.layers[0].div, wheelDelta: delta}); t.delay_call(1, function() { From 1a25a0704fe35054190c5d2c181d88969f81d57a Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Tue, 29 May 2012 14:21:49 +0200 Subject: [PATCH 07/17] Changed to test for WebKit instead of safari because chrome was added to the OpenLayers.BROWSER_NAME test --- lib/OpenLayers/Util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 18ebe0a420..3cbe1bc74c 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -1233,7 +1233,7 @@ OpenLayers.Util.pagePosition = function(forElement) { var browser = OpenLayers.BROWSER_NAME; // opera & (safari absolute) incorrectly account for body offsetTop - if (browser == "opera" || (browser == "safari" && + if (browser == "opera" || (OpenLayers.IS_WEBKIT && OpenLayers.Element.getStyle(forElement, 'position') == 'absolute')) { pos[1] -= document.body.offsetTop; } From 8f38ba5bd019e93eabcdd93306adb3d5e76d00ac Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Tue, 29 May 2012 16:08:15 +0200 Subject: [PATCH 08/17] Chagned APIProperty to Property for isAnalogScrollWheel --- lib/OpenLayers/Handler/MouseWheel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Handler/MouseWheel.js b/lib/OpenLayers/Handler/MouseWheel.js index c21459a6cb..8a3aa679e3 100644 --- a/lib/OpenLayers/Handler/MouseWheel.js +++ b/lib/OpenLayers/Handler/MouseWheel.js @@ -56,7 +56,7 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, { cumulative: true, /** - * APIProperty: isAnalogScrollWheel + * Property: isAnalogScrollWheel * {Boolean} Will switch to true when an event with analog scroll value * is detected. */ From f5a9b4446a17eb016d3d16ae93fc45a12020ffd4 Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Tue, 29 May 2012 16:11:30 +0200 Subject: [PATCH 09/17] Added analog scroll wheel improvements to 2.13 changelog --- notes/2.13.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/notes/2.13.md b/notes/2.13.md index c8d0938d6c..bed9bee7c6 100644 --- a/notes/2.13.md +++ b/notes/2.13.md @@ -7,3 +7,11 @@ Previously, objects generated by the library were given id properties with value Corresponding issues/pull requests: * https://github.com/openlayers/openlayers/pull/416 + +## Better support for analog scroll wheel + +Removed rounding of zoom level for maps with fractionalZoom == true. So users with an OS and interface device with analog scroll support will now get smooth zooming. + +Corresponding issues/pull requests: + + * https://github.com/openlayers/openlayers/pull/483 \ No newline at end of file From dc082c3442055ce55be49f71a6c20644e4c2f9aa Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Tue, 29 May 2012 17:03:33 +0200 Subject: [PATCH 10/17] Added note that chrome was added to the BROWSER_NAME test --- notes/2.13.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/notes/2.13.md b/notes/2.13.md index bed9bee7c6..8471aa6c68 100644 --- a/notes/2.13.md +++ b/notes/2.13.md @@ -14,4 +14,12 @@ Removed rounding of zoom level for maps with fractionalZoom == true. So users wi Corresponding issues/pull requests: - * https://github.com/openlayers/openlayers/pull/483 \ No newline at end of file + * https://github.com/openlayers/openlayers/pull/483 + + ## "chrome" added to OpenLayers.BROWSER_NAME + +Chrome was incorrectly detected as "safari". Code that expect OpenLayers.BROWSER_NAME to be "safari" in Google Chrome will cause problems. Test for "chrome" as well, or use the new OpenLayers.IS_WEBKIT. + + Corresponding issues/pull requests: + + * https://github.com/openlayers/openlayers/pull/483 \ No newline at end of file From dd410dcd7e1ecde833fd6e2c593df39777edba29 Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Tue, 29 May 2012 17:08:01 +0200 Subject: [PATCH 11/17] Fixed indentation --- notes/2.13.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notes/2.13.md b/notes/2.13.md index 8471aa6c68..4847832d19 100644 --- a/notes/2.13.md +++ b/notes/2.13.md @@ -16,10 +16,10 @@ Corresponding issues/pull requests: * https://github.com/openlayers/openlayers/pull/483 - ## "chrome" added to OpenLayers.BROWSER_NAME +## "chrome" added to OpenLayers.BROWSER_NAME Chrome was incorrectly detected as "safari". Code that expect OpenLayers.BROWSER_NAME to be "safari" in Google Chrome will cause problems. Test for "chrome" as well, or use the new OpenLayers.IS_WEBKIT. - Corresponding issues/pull requests: +Corresponding issues/pull requests: * https://github.com/openlayers/openlayers/pull/483 \ No newline at end of file From 2da16a0b696720681809c2ce7e75e00c0e1cabbb Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Tue, 29 May 2012 17:54:02 +0200 Subject: [PATCH 12/17] Removed caching of the analog wheel detection for users switching between mouse/touchpad --- lib/OpenLayers/Handler/MouseWheel.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/OpenLayers/Handler/MouseWheel.js b/lib/OpenLayers/Handler/MouseWheel.js index 8a3aa679e3..3dbb1ef51f 100644 --- a/lib/OpenLayers/Handler/MouseWheel.js +++ b/lib/OpenLayers/Handler/MouseWheel.js @@ -55,13 +55,6 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, { */ cumulative: true, - /** - * Property: isAnalogScrollWheel - * {Boolean} Will switch to true when an event with analog scroll value - * is detected. - */ - isAnalogScrollWheel: false, - /** * Property: analogWheelPrecision * {Integer} Adjust to get analog scroll wheel to feel right @@ -186,17 +179,21 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, { if (e.wheelDelta) { delta = e.wheelDelta; - if (OpenLayers.BROWSER_NAME === "safari" && !this.isAnalogScrollWheel) { + if (OpenLayers.BROWSER_NAME === "safari") { + // Safari has a value 10 times other browsers delta = delta * 10; } else if (window.opera && window.opera.version() < 9.2) { delta = -delta; } - this.isAnalogScrollWheel = (this.isAnalogScrollWheel || - delta % 40 !== 0 || Math.abs(delta) < 120); + var isAnalogScrollWheel = (delta % 40 !== 0 || Math.abs(delta) < 120); - if (this.isAnalogScrollWheel) { + if (isAnalogScrollWheel) { delta = delta / this.analogWheelPrecision; + if (OpenLayers.BROWSER_NAME === "safari") { + // Undo the Safari multiplying for analog scrolling + delta = delta / 10; + } } else { delta = Math.round(delta / 120); } From 51c7f1248614f9883ba5bb29c91908f5c5f0ccfc Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Tue, 29 May 2012 18:18:24 +0200 Subject: [PATCH 13/17] Avoid logic change from existing code --- lib/OpenLayers/Util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 3cbe1bc74c..43dc5b929b 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -1233,7 +1233,7 @@ OpenLayers.Util.pagePosition = function(forElement) { var browser = OpenLayers.BROWSER_NAME; // opera & (safari absolute) incorrectly account for body offsetTop - if (browser == "opera" || (OpenLayers.IS_WEBKIT && + if (browser == "opera" || ((browser == "safari" || browser == "chrome") && OpenLayers.Element.getStyle(forElement, 'position') == 'absolute')) { pos[1] -= document.body.offsetTop; } From f7f763d1d3ac0275a83b64d129d486c2ec3b7bbb Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Wed, 30 May 2012 14:37:43 +0200 Subject: [PATCH 14/17] Removed analog wheel detection and simplified code --- lib/OpenLayers/Handler/MouseWheel.js | 32 ++++++---------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/lib/OpenLayers/Handler/MouseWheel.js b/lib/OpenLayers/Handler/MouseWheel.js index 3dbb1ef51f..144bb285d9 100644 --- a/lib/OpenLayers/Handler/MouseWheel.js +++ b/lib/OpenLayers/Handler/MouseWheel.js @@ -55,12 +55,6 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, { */ cumulative: true, - /** - * Property: analogWheelPrecision - * {Integer} Adjust to get analog scroll wheel to feel right - */ - analogWheelPrecision: 360, - /** * Constructor: OpenLayers.Handler.MouseWheel * @@ -178,27 +172,15 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, { if (e.wheelDelta) { delta = e.wheelDelta; - - if (OpenLayers.BROWSER_NAME === "safari") { - // Safari has a value 10 times other browsers - delta = delta * 10; - } else if (window.opera && window.opera.version() < 9.2) { - delta = -delta; - } - - var isAnalogScrollWheel = (delta % 40 !== 0 || Math.abs(delta) < 120); - - if (isAnalogScrollWheel) { - delta = delta / this.analogWheelPrecision; - if (OpenLayers.BROWSER_NAME === "safari") { - // Undo the Safari multiplying for analog scrolling - delta = delta / 10; - } - } else { - delta = Math.round(delta / 120); + if (delta % 160 === 0) { + // opera have steps of 160 instead of 120 + delta = delta * 0.75; } + delta = delta / 120; } else if (e.detail) { - delta = -e.detail / 3; + // detail in Firefox on OS X is 1/3 of Windows + // so force delta 1 / -1 + delta = - (e.detail / Math.abs(e.detail)); } this.delta = this.delta + delta; From 2725cd93f605e8ff7fb3f2625ed997f42b9734f7 Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Wed, 30 May 2012 15:01:25 +0200 Subject: [PATCH 15/17] Reverted chrome added to BROWSER_NAME --- lib/OpenLayers/Util.js | 15 ++------------- notes/2.13.md | 10 +--------- tests/deprecated/Layer/MapServer.html | 4 ++-- tests/deprecated/Layer/WMS.html | 2 +- 4 files changed, 6 insertions(+), 25 deletions(-) diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 43dc5b929b..ac598f2604 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -1233,7 +1233,7 @@ OpenLayers.Util.pagePosition = function(forElement) { var browser = OpenLayers.BROWSER_NAME; // opera & (safari absolute) incorrectly account for body offsetTop - if (browser == "opera" || ((browser == "safari" || browser == "chrome") && + if (browser == "opera" || (browser == "safari" && OpenLayers.Element.getStyle(forElement, 'position') == 'absolute')) { pos[1] -= document.body.offsetTop; } @@ -1439,22 +1439,13 @@ OpenLayers.Util.removeTail = function(url) { return head; }; -/** - * Constant: IS_WEBKIT - * {Boolean} True if the userAgent reports the browser to use the WebKit engine - */ -OpenLayers.IS_WEBKIT = (function() { - var ua = navigator.userAgent.toLowerCase(); - return ua.indexOf("webkit") !== -1; -})(); - /** * Constant: IS_GECKO * {Boolean} True if the userAgent reports the browser to use the Gecko engine */ OpenLayers.IS_GECKO = (function() { var ua = navigator.userAgent.toLowerCase(); - return !OpenLayers.IS_WEBKIT && ua.indexOf("gecko") !== -1; + return ua.indexOf("webkit") == -1 && ua.indexOf("gecko") != -1; })(); /** @@ -1484,8 +1475,6 @@ OpenLayers.BROWSER_NAME = (function() { name = "opera"; } else if (ua.indexOf("msie") != -1) { name = "msie"; - } else if(ua.indexOf("chrome") != -1) { - name = "chrome"; } else if (ua.indexOf("safari") != -1) { name = "safari"; } else if (ua.indexOf("mozilla") != -1) { diff --git a/notes/2.13.md b/notes/2.13.md index 4847832d19..bed9bee7c6 100644 --- a/notes/2.13.md +++ b/notes/2.13.md @@ -14,12 +14,4 @@ Removed rounding of zoom level for maps with fractionalZoom == true. So users wi Corresponding issues/pull requests: - * https://github.com/openlayers/openlayers/pull/483 - -## "chrome" added to OpenLayers.BROWSER_NAME - -Chrome was incorrectly detected as "safari". Code that expect OpenLayers.BROWSER_NAME to be "safari" in Google Chrome will cause problems. Test for "chrome" as well, or use the new OpenLayers.IS_WEBKIT. - -Corresponding issues/pull requests: - - * https://github.com/openlayers/openlayers/pull/483 \ No newline at end of file + * https://github.com/openlayers/openlayers/pull/483 \ No newline at end of file diff --git a/tests/deprecated/Layer/MapServer.html b/tests/deprecated/Layer/MapServer.html index ec6e7a5792..27ce63dd20 100644 --- a/tests/deprecated/Layer/MapServer.html +++ b/tests/deprecated/Layer/MapServer.html @@ -18,9 +18,9 @@ (window.location.host == "localhost") || (window.location.host == "openlayers.org"); - if (OpenLayers.BROWSER_NAME == "opera" || OpenLayers.IS_WEBKIT) { + if (OpenLayers.BROWSER_NAME == "opera" || OpenLayers.BROWSER_NAME == "safari") { t.plan(1); - t.debug_print("Can't test google reprojection in Opera or WebKit."); + t.debug_print("Can't test google reprojection in Opera or Safari."); } else if(validkey) { t.plan(5); var map = new OpenLayers.Map('map'); diff --git a/tests/deprecated/Layer/WMS.html b/tests/deprecated/Layer/WMS.html index cca85ffc83..523d6eef12 100644 --- a/tests/deprecated/Layer/WMS.html +++ b/tests/deprecated/Layer/WMS.html @@ -16,7 +16,7 @@ var validkey = (window.location.protocol == "file:") || (window.location.host == "localhost") || (window.location.host == "openlayers.org"); - if (OpenLayers.BROWSER_NAME == "opera" || OpenLayers.IS_WEBKIT) { + if (OpenLayers.BROWSER_NAME == "opera" || OpenLayers.BROWSER_NAME == "safari") { t.plan(1); t.debug_print("Can't test google reprojection in Opera or Safari."); } else if(validkey) { From 09058e24577a4d67504a5286a3a152863d7d1937 Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Wed, 30 May 2012 15:02:29 +0200 Subject: [PATCH 16/17] Reverted deletion of fix for Opera < 9.2 --- lib/OpenLayers/Handler/MouseWheel.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/OpenLayers/Handler/MouseWheel.js b/lib/OpenLayers/Handler/MouseWheel.js index 144bb285d9..007a42f887 100644 --- a/lib/OpenLayers/Handler/MouseWheel.js +++ b/lib/OpenLayers/Handler/MouseWheel.js @@ -172,6 +172,9 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, { if (e.wheelDelta) { delta = e.wheelDelta; + if (window.opera && window.opera.version() < 9.2) { + delta = -delta; + } if (delta % 160 === 0) { // opera have steps of 160 instead of 120 delta = delta * 0.75; From dc69749e3b1622839daa1223c2281d7d13ed401e Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Wed, 30 May 2012 15:05:27 +0200 Subject: [PATCH 17/17] Reverted Safari hack for MouseWheel test --- tests/Handler/MouseWheel.html | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Handler/MouseWheel.html b/tests/Handler/MouseWheel.html index 251a879e9c..0ec9505fb7 100644 --- a/tests/Handler/MouseWheel.html +++ b/tests/Handler/MouseWheel.html @@ -109,7 +109,6 @@ var delta = 120; if (window.opera && window.opera.version() < 9.2) { delta = -delta; } - if (OpenLayers.BROWSER_NAME === "safari") delta = delta / 10; handler.onWheelEvent({'target':map.layers[0].div, wheelDelta: delta}); handler.onWheelEvent({'target':map.layers[0].div, wheelDelta: delta}); t.delay_call(1, function() {