Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mapbox/mapbox-gl-js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.5.0
Choose a base ref
...
head repository: mapbox/mapbox-gl-js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.5.1
Choose a head ref
  • 2 commits
  • 14 files changed
  • 2 contributors

Commits on Oct 6, 2021

  1. Fix an iOS15 issue where Safari tab bar interrupts panning (#11084) (#…

    …11089)
    
    * fix an iOS15 issue where map stops when panning
    
    * fix tests and lint
    
    * Test drag pan handler does not end interaction on resize
    
    * Move blur event reset into non-touch handlers (#11087)
    
    * Move blur event reset into non-touch handlers
    
    * Fix linter
    
    * Fix/amend unit tests
    
    * Flush task queue in rotate test
    
    Co-authored-by: Ricky Reusser <ricky.reusser@mapbox.com>
    Co-authored-by: Ricky Reusser <rreusser@users.noreply.github.com>
    
    Co-authored-by: Vladimir Agafonkin <agafonkin@gmail.com>
    rreusser and mourner authored Oct 6, 2021
    Copy the full SHA
    a884ab3 View commit details
  2. Update version and add changelog entry (#11097)

    * Update version and add changelog entry
    
    * Fix typo
    
    * Fix another typo
    rreusser authored Oct 6, 2021
    Copy the full SHA
    a3b52aa View commit details
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.5.1

### 🐞 Bug fixes

* Fix an iOS 15 issue where the iOS Safari tab bar interrupts touch interactions. ([#11084](https://github.com/mapbox/mapbox-gl-js/pull/11084))

## 2.5.0

### Features ✨ and improvements 🏁
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mapbox-gl",
"description": "A WebGL interactive maps library",
"version": "2.5.0",
"version": "2.5.1",
"main": "dist/mapbox-gl.js",
"style": "dist/mapbox-gl.css",
"license": "SEE LICENSE IN LICENSE.txt",
4 changes: 4 additions & 0 deletions src/ui/handler/box_zoom.js
Original file line number Diff line number Diff line change
@@ -153,6 +153,10 @@ class BoxZoomHandler {
}
}

blur() {
this.reset();
}

reset() {
this._active = false;

4 changes: 4 additions & 0 deletions src/ui/handler/click_zoom.js
Original file line number Diff line number Diff line change
@@ -16,6 +16,10 @@ export default class ClickZoomHandler {
this._active = false;
}

blur() {
this.reset();
}

dblclick(e: MouseEvent, point: Point) {
e.preventDefault();
return {
4 changes: 4 additions & 0 deletions src/ui/handler/keyboard.js
Original file line number Diff line number Diff line change
@@ -45,6 +45,10 @@ class KeyboardHandler {
this._rotationDisabled = false;
}

blur() {
this.reset();
}

reset() {
this._active = false;
}
4 changes: 4 additions & 0 deletions src/ui/handler/mouse.js
Original file line number Diff line number Diff line change
@@ -31,6 +31,10 @@ class MouseHandler {
this._clickTolerance = options.clickTolerance || 1;
}

blur() {
this.reset();
}

reset() {
this._active = false;
this._moved = false;
4 changes: 4 additions & 0 deletions src/ui/handler/scroll_zoom.js
Original file line number Diff line number Diff line change
@@ -353,6 +353,10 @@ class ScrollZoomHandler {
return easing;
}

blur() {
this.reset();
}

reset() {
this._active = false;
}
5 changes: 0 additions & 5 deletions src/ui/handler_manager.js
Original file line number Diff line number Diff line change
@@ -344,11 +344,6 @@ class HandlerManager {

handleEvent(e: InputEvent | RenderFrameEvent, eventName?: string) {

if (e.type === 'blur') {
this.stop(true);
return;
}

this._updatingCamera = true;
assert(e.timeStamp !== undefined);

8 changes: 4 additions & 4 deletions src/ui/map.js
Original file line number Diff line number Diff line change
@@ -691,9 +691,10 @@ class Map extends Camera {
* if (mapDiv.style.visibility === true) map.resize();
*/
resize(eventData?: Object) {
const dimensions = this._containerDimensions();
const width = dimensions[0];
const height = dimensions[1];
const [width, height] = this._containerDimensions();

// do nothing if container remained the same size
if (width === this.transform.width && height === this.transform.height) return this;

this._resizeCanvas(width, height);

@@ -702,7 +703,6 @@ class Map extends Camera {

const fireMoving = !this._moving;
if (fireMoving) {
this.stop();
this.fire(new Event('movestart', eventData))
.fire(new Event('move', eventData));
}
4 changes: 4 additions & 0 deletions test/unit/ui/control/attribution.test.js
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ test('AttributionControl appears in the position specified by the position optio

test('AttributionControl appears in compact mode if compact option is used', (t) => {
const map = createMap(t);
Object.defineProperty(map.getContainer(), 'getBoundingClientRect', {value: () => ({height: 200, width: 700})});
Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 700, configurable: true});

let attributionControl = new AttributionControl({
@@ -49,6 +50,7 @@ test('AttributionControl appears in compact mode if compact option is used', (t)
t.equal(container.querySelectorAll('.mapboxgl-ctrl-attrib.mapboxgl-compact').length, 1);
map.removeControl(attributionControl);

Object.defineProperty(map.getContainer(), 'getBoundingClientRect', {value: () => ({height: 200, width: 600})});
Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 600, configurable: true});
attributionControl = new AttributionControl({
compact: false
@@ -61,13 +63,15 @@ test('AttributionControl appears in compact mode if compact option is used', (t)

test('AttributionControl appears in compact mode if container is less then 640 pixel wide', (t) => {
const map = createMap(t);
Object.defineProperty(map.getContainer(), 'getBoundingClientRect', {value: () => ({height: 200, width: 700})});
Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 700, configurable: true});
map.addControl(new AttributionControl());

const container = map.getContainer();

t.equal(container.querySelectorAll('.mapboxgl-ctrl-attrib:not(.mapboxgl-compact)').length, 1);

Object.defineProperty(map.getContainer(), 'getBoundingClientRect', {value: () => ({height: 200, width: 600})});
Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 600, configurable: true});
map.resize();

4 changes: 4 additions & 0 deletions test/unit/ui/control/logo.test.js
Original file line number Diff line number Diff line change
@@ -104,12 +104,16 @@ test('LogoControl appears in compact mode if container is less then 250 pixel wi
const map = createMap(t);
const container = map.getContainer();

Object.defineProperty(map.getContainer(), 'getBoundingClientRect', {value: () => ({height: 200, width: 255})});
Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 255, configurable: true});
map.resize();

t.equal(container.querySelectorAll('.mapboxgl-ctrl-logo:not(.mapboxgl-compact)').length, 1);

Object.defineProperty(map.getContainer(), 'getBoundingClientRect', {value: () => ({height: 200, width: 245})});
Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 245, configurable: true});
map.resize();

t.equal(container.querySelectorAll('.mapboxgl-ctrl-logo.mapboxgl-compact').length, 1);

t.end();
37 changes: 36 additions & 1 deletion test/unit/ui/handler/drag_pan.test.js
Original file line number Diff line number Diff line change
@@ -151,13 +151,15 @@ test('DragPanHandler ends a mouse-triggered drag if the window blurs', (t) => {
map._renderTaskQueue.run();

simulate.blur(window);
map._renderTaskQueue.run();

t.equal(dragend.callCount, 1);

map.remove();
t.end();
});

test('DragPanHandler ends a touch-triggered drag if the window blurs', (t) => {
test('DragPanHandler does not end a touch-triggered drag if the window blurs', (t) => {
const map = createMap(t);
const target = map.getCanvas();

@@ -171,7 +173,40 @@ test('DragPanHandler ends a touch-triggered drag if the window blurs', (t) => {
map._renderTaskQueue.run();

simulate.blur(window);
map._renderTaskQueue.run();

t.equal(dragend.callCount, 0);

map.remove();
t.end();
});

test('DragPanHandler does not end a touch-triggered drag if the window resizes', (t) => {
const map = createMap(t);
const target = map.getCanvas();

const dragend = t.spy();
map.on('dragend', dragend);

const drag = t.spy();
map.on('drag', drag);

simulate.touchstart(map.getCanvas(), {touches: [{target, clientX: 0, clientY: 0}]});
map._renderTaskQueue.run();

simulate.touchmove(map.getCanvas(), {touches: [{target, clientX: 10, clientY: 10}]});
map._renderTaskQueue.run();

map.resize();

simulate.touchmove(map.getCanvas(), {touches: [{target, clientX: 20, clientY: 10}]});
map._renderTaskQueue.run();

simulate.touchend(map.getCanvas());
map._renderTaskQueue.run();

t.equal(dragend.callCount, 1);
t.equal(drag.callCount, 2);

map.remove();
t.end();
2 changes: 2 additions & 0 deletions test/unit/ui/handler/drag_rotate.test.js
Original file line number Diff line number Diff line change
@@ -492,6 +492,8 @@ test('DragRotateHandler ends rotation if the window blurs (#3389)', (t) => {
t.equal(rotate.callCount, 1);

simulate.blur(window);
map._renderTaskQueue.run();

t.equal(rotateend.callCount, 1);

map.remove();
32 changes: 32 additions & 0 deletions test/unit/ui/map.test.js
Original file line number Diff line number Diff line change
@@ -764,10 +764,42 @@ test('Map', (t) => {
t.end();
});

t.test('does nothing if container size is the same', (t) => {
const map = createMap(t);

t.spy(map.transform, 'resize');
t.spy(map.painter, 'resize');

map.resize();

t.notOk(map.transform.resize.called);
t.notOk(map.painter.resize.called);

t.end();
});

t.test('does not call stop on resize', (t) => {
const map = createMap(t);

Object.defineProperty(map.getContainer(), 'getBoundingClientRect',
{value: () => ({height: 250, width: 250})});

t.spy(map, 'stop');

map.resize();

t.notOk(map.stop.called);

t.end();
});

t.test('fires movestart, move, resize, and moveend events', (t) => {
const map = createMap(t),
events = [];

Object.defineProperty(map.getContainer(), 'getBoundingClientRect',
{value: () => ({height: 250, width: 250})});

['movestart', 'move', 'resize', 'moveend'].forEach((event) => {
map.on(event, (e) => {
events.push(e.type);