From d743ada8fd17438c89c29a954e70e01d49df6311 Mon Sep 17 00:00:00 2001 From: Nicholas L Date: Sun, 17 Jan 2016 16:35:26 +1300 Subject: [PATCH] Remove goog.array.remove --- src/ol/array.js | 15 +++++++++++++++ src/ol/map.js | 4 ++-- src/ol/pointer/touchsource.js | 4 ++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/ol/array.js b/src/ol/array.js index 21a468b43f..7e4c4107ee 100644 --- a/src/ol/array.js +++ b/src/ol/array.js @@ -158,3 +158,18 @@ ol.array.extend = function(arr, data) { arr[arr.length] = extension[i]; } } + + +/** + * @param {Array} arr The array to modify. + * @param {VALUE} obj The element to remove. + * @template VALUE + * @return {boolean} If the element was removed. + */ +ol.array.remove = function(arr, obj) { + var i = arr.indexOf(obj); + if (i > -1) { + arr.splice(i, 1); + } + return i > -1; +} diff --git a/src/ol/map.js b/src/ol/map.js index 2e9faa1794..700ec6754e 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -5,7 +5,6 @@ goog.provide('ol.Map'); goog.provide('ol.MapProperty'); -goog.require('goog.array'); goog.require('goog.asserts'); goog.require('goog.async.AnimationDelay'); goog.require('goog.async.nextTick'); @@ -45,6 +44,7 @@ goog.require('ol.Size'); goog.require('ol.TileQueue'); goog.require('ol.View'); goog.require('ol.ViewHint'); +goog.require('ol.array'); goog.require('ol.control'); goog.require('ol.extent'); goog.require('ol.has'); @@ -574,7 +574,7 @@ ol.Map.prototype.beforeRender = function(var_args) { * @return {boolean} Whether the preRenderFunction has been found and removed. */ ol.Map.prototype.removePreRenderFunction = function(preRenderFunction) { - return goog.array.remove(this.preRenderFunctions_, preRenderFunction); + return ol.array.remove(this.preRenderFunctions_, preRenderFunction); }; diff --git a/src/ol/pointer/touchsource.js b/src/ol/pointer/touchsource.js index 820cb15eb4..eb760009e7 100644 --- a/src/ol/pointer/touchsource.js +++ b/src/ol/pointer/touchsource.js @@ -30,11 +30,11 @@ goog.provide('ol.pointer.TouchSource'); -goog.require('goog.array'); goog.require('goog.object'); goog.require('ol'); goog.require('ol.pointer.EventSource'); goog.require('ol.pointer.MouseSource'); +goog.require('ol.array'); /** @@ -443,7 +443,7 @@ ol.pointer.TouchSource.prototype.dedupSynthMouse_ = function(inEvent) { goog.global.setTimeout(function() { // remove touch after timeout - goog.array.remove(lts, lt); + ol.array.remove(lts, lt); }, ol.pointer.TouchSource.DEDUP_TIMEOUT); } };