diff --git a/src/data/program_configuration.js b/src/data/program_configuration.js index 95cbd501db0..04dd5c05cfb 100644 --- a/src/data/program_configuration.js +++ b/src/data/program_configuration.js @@ -6,6 +6,7 @@ import {supportsPropertyExpression} from '../style-spec/util/properties'; import {register, serialize, deserialize} from '../util/web_worker_transfer'; import {PossiblyEvaluatedPropertyValue} from '../style/properties'; import {StructArrayLayout1f4, StructArrayLayout2f8, StructArrayLayout4f16, PatternLayoutArray} from './array_types'; +import {clamp} from '../util/util'; import EvaluationParameters from '../style/evaluation_parameters'; import FeaturePositionMap from './feature_position_map'; @@ -381,10 +382,9 @@ class CompositeExpressionBinder implements Binder { interpolationFactor(currentZoom: number) { if (this.useIntegerZoom) { - return this.expression.interpolationFactor(Math.floor(currentZoom), this.zoom, this.zoom + 1); - } else { - return this.expression.interpolationFactor(currentZoom, this.zoom, this.zoom + 1); + currentZoom = Math.floor(currentZoom); } + return clamp(this.expression.interpolationFactor(currentZoom, this.zoom, this.zoom + 1), 0, 1); } setUniforms(context: Context, uniform: Uniform<*>, diff --git a/test/integration/render-tests/regressions/mapbox-gl-js#8817/expected.png b/test/integration/render-tests/regressions/mapbox-gl-js#8817/expected.png new file mode 100644 index 00000000000..b36e37b0862 Binary files /dev/null and b/test/integration/render-tests/regressions/mapbox-gl-js#8817/expected.png differ diff --git a/test/integration/render-tests/regressions/mapbox-gl-js#8817/style.json b/test/integration/render-tests/regressions/mapbox-gl-js#8817/style.json new file mode 100644 index 00000000000..7799971f603 --- /dev/null +++ b/test/integration/render-tests/regressions/mapbox-gl-js#8817/style.json @@ -0,0 +1,68 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 64, + "height": 64, + "comment": "The `pauseSource` prevents new tiles from loading and forces the map to use tiles outside of their ideal zoom range.", + "operations": [ + ["pauseSource", "geojson"], + ["setZoom", 2], + ["wait"] + ] + } + }, + "zoom": 0, + "sources": { + "geojson": { + "type": "geojson", + "data": { + "type": "Polygon", + "coordinates": [ + [ + [ + -10, + -10 + ], + [ + -10, + 10 + ], + [ + 10, + 10 + ], + [ + 10, + -10 + ], + [ + -10, + -10 + ] + ] + ] + } + } + }, + "layers": [ + { + "id": "fill", + "type": "fill", + "source": "geojson", + "paint": { + "fill-antialias": false, + "fill-color": "green", + "fill-opacity": [ + "interpolate", + ["linear"], + ["zoom"], + 0.5, + 0, + 1, + ["match", ["get", "fakeproptotriggercompositeexpression"], "nope", 1, 1] + ] + } + } + ] +} diff --git a/test/suite_implementation.js b/test/suite_implementation.js index 7c597f74f0f..b9112f5554f 100644 --- a/test/suite_implementation.js +++ b/test/suite_implementation.js @@ -172,6 +172,9 @@ module.exports = function(style, options, _callback) { // eslint-disable-line im // consistent local ideograph rendering using fixtures in all runs of the test suite. map.setStyle(operation[1], {localIdeographFontFamily: false}); applyOperations(map, operations.slice(1), callback); + } else if (operation[0] === 'pauseSource') { + map.style.sourceCaches[operation[1]].pause(); + applyOperations(map, operations.slice(1), callback); } else { map[operation[0]](...operation.slice(1)); applyOperations(map, operations.slice(1), callback);