Merge pull request #1693 from ahocevar/no-load-on-interacting

Do not load tiles while interacting
This commit is contained in:
ahocevar
2014-02-13 23:29:00 +01:00
2 changed files with 29 additions and 2 deletions
+9
View File
@@ -6,6 +6,13 @@
* @todo stability experimental * @todo stability experimental
*/ */
/**
* @typedef {Object} olx.DeviceOptions
* @property {boolean|undefined} loadTilesWhileAnimating When set to false, no tiles will be loaded while animating, which improves responsiveness on devices with slow memory. Default is `true`.
* @property {boolean|undefined} loadTilesWhileInteracting When set to false, no tiles will be loaded while interacting, which improves responsiveness on devices with slow memory. Default is `true`.
* @todo stability experimental
*/
/** /**
* @typedef {Object} olx.DeviceOrientationOptions * @typedef {Object} olx.DeviceOrientationOptions
* @property {boolean|undefined} tracking Start tracking. Default is `false`. * @property {boolean|undefined} tracking Start tracking. Default is `false`.
@@ -25,6 +32,8 @@
* @typedef {Object} olx.MapOptions * @typedef {Object} olx.MapOptions
* @property {ol.Collection|Array.<ol.control.Control>|undefined} controls * @property {ol.Collection|Array.<ol.control.Control>|undefined} controls
* Controls initially added to the map. * Controls initially added to the map.
* @property {olx.DeviceOptions|undefined} deviceOptions
* Device options for the map.
* @property {number|undefined} pixelRatio The ratio between physical * @property {number|undefined} pixelRatio The ratio between physical
* pixels and device-independent pixels (dips) on the device. If `undefined` * pixels and device-independent pixels (dips) on the device. If `undefined`
* then it gets set by using `window.devicePixelRatio`. * then it gets set by using `window.devicePixelRatio`.
+20 -2
View File
@@ -311,6 +311,12 @@ ol.Map = function(options) {
*/ */
this.controls_ = optionsInternal.controls; this.controls_ = optionsInternal.controls;
/**
* @type {olx.DeviceOptions}
* @private
*/
this.deviceOptions_ = optionsInternal.deviceOptions;
/** /**
* @type {ol.Collection} * @type {ol.Collection}
* @private * @private
@@ -827,8 +833,15 @@ ol.Map.prototype.handlePostRender = function() {
var tileSourceCount = 0; var tileSourceCount = 0;
if (!goog.isNull(frameState)) { if (!goog.isNull(frameState)) {
var hints = frameState.viewHints; var hints = frameState.viewHints;
if (hints[ol.ViewHint.ANIMATING] || hints[ol.ViewHint.INTERACTING]) { var deviceOptions = this.deviceOptions_;
maxTotalLoading = 8; if (hints[ol.ViewHint.ANIMATING]) {
maxTotalLoading = deviceOptions.loadTilesWhileAnimating === false ?
0 : 8;
maxNewLoads = 2;
}
if (hints[ol.ViewHint.INTERACTING]) {
maxTotalLoading = deviceOptions.loadTilesWhileInteracting === false ?
0 : 8;
maxNewLoads = 2; maxNewLoads = 2;
} }
tileSourceCount = goog.object.getCount(frameState.wantedTiles); tileSourceCount = goog.object.getCount(frameState.wantedTiles);
@@ -1316,6 +1329,7 @@ ol.Map.prototype.withFrozenRendering = function(f, opt_this) {
/** /**
* @typedef {{controls: ol.Collection, * @typedef {{controls: ol.Collection,
* deviceOptions: olx.DeviceOptions,
* interactions: ol.Collection, * interactions: ol.Collection,
* keyboardEventTarget: (Element|Document), * keyboardEventTarget: (Element|Document),
* ol3Logo: boolean, * ol3Logo: boolean,
@@ -1416,6 +1430,9 @@ ol.Map.createOptionsInternal = function(options) {
controls = ol.control.defaults(); controls = ol.control.defaults();
} }
var deviceOptions = goog.isDef(options.deviceOptions) ?
options.deviceOptions : /** @type {olx.DeviceOptions} */ ({});
var interactions; var interactions;
if (goog.isDef(options.interactions)) { if (goog.isDef(options.interactions)) {
if (goog.isArray(options.interactions)) { if (goog.isArray(options.interactions)) {
@@ -1442,6 +1459,7 @@ ol.Map.createOptionsInternal = function(options) {
return { return {
controls: controls, controls: controls,
deviceOptions: deviceOptions,
interactions: interactions, interactions: interactions,
keyboardEventTarget: keyboardEventTarget, keyboardEventTarget: keyboardEventTarget,
ol3Logo: ol3Logo, ol3Logo: ol3Logo,