Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_applyConstraints(props: ViewportProps): ViewportProps {
// Ensure zoom is within specified range
const {maxZoom, minZoom, zoom} = props;
props.zoom = clamp(zoom, minZoom, maxZoom);
// Ensure pitch is within specified range
const {maxPitch, minPitch, pitch} = props;
props.pitch = clamp(pitch, minPitch, maxPitch);
Object.assign(props, normalizeViewportProps(props));
return props;
}
_applyConstraints(props) {
// Ensure zoom is within specified range
const {maxZoom, minZoom, zoom} = props;
props.zoom = clamp(zoom, minZoom, maxZoom);
// Ensure pitch is within specified range
const {maxPitch, minPitch, pitch} = props;
props.pitch = clamp(pitch, minPitch, maxPitch);
Object.assign(props, normalizeViewportProps(props));
return props;
}
test('normalizeViewportProps', (t) => {
config.EPSILON = 1e-7;
for (const [input, expected] of NORMALIZATION_TEST_CASES) {
const result = normalizeViewportProps(input);
t.ok(equals(
Object.keys(expected).map(key => result[key]),
Object.keys(expected).map(key => expected[key])
),
'correct viewport returned'
);
}
t.end();
});