Skip to content

Commit

Permalink
Revert "Prevent changing bearing via URL hash when rotation is disabl…
Browse files Browse the repository at this point in the history
…ed (#9156)"

This reverts commit 93b9916.
  • Loading branch information
Anjana Vakil committed Jan 7, 2020
1 parent 9922ab0 commit 164f7ba
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 34 deletions.
3 changes: 1 addition & 2 deletions src/ui/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,10 @@ class Hash {
_onHashChange() {
const loc = this._getCurrentHash();
if (loc.length >= 3 && !loc.some(v => isNaN(v))) {
const bearing = this._map.dragRotate.isEnabled() && this._map.touchZoomRotate.isEnabled() ? +loc[3] : this._map.getBearing();
this._map.jumpTo({
center: [+loc[2], +loc[1]],
zoom: +loc[0],
bearing,
bearing: +(loc[3] || 0),
pitch: +(loc[4] || 0)
});
return true;
Expand Down
32 changes: 0 additions & 32 deletions test/unit/ui/hash.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ test('hash', (t) => {
t.equal(map.getBearing(), 0);
t.equal(map.getPitch(), 0);

// map is created with `interactive: false`
// so explicitly enable rotation for this test
map.dragRotate.enable();
map.touchZoomRotate.enable();

window.location.hash = '#5/1.00/0.50/30/60';

hash._onHashChange();
Expand All @@ -72,33 +67,6 @@ test('hash', (t) => {
t.equal(map.getBearing(), 30);
t.equal(map.getPitch(), 60);

// disable rotation to test that updating
// the hash's bearing won't change the map
map.dragRotate.disable();
map.touchZoomRotate.disable();

window.location.hash = '#5/1.00/0.50/-45/60';

hash._onHashChange();

t.equal(map.getCenter().lng, 0.5);
t.equal(map.getCenter().lat, 1);
t.equal(map.getZoom(), 5);
t.equal(map.getBearing(), 30);
t.equal(map.getPitch(), 60);

// test that a hash with no bearing resets
// to the previous bearing when rotation is disabled
window.location.hash = '#5/1.00/0.50/';

hash._onHashChange();

t.equal(map.getCenter().lng, 0.5);
t.equal(map.getCenter().lat, 1);
t.equal(map.getZoom(), 5);
t.equal(map.getBearing(), 30);
t.equal(window.location.hash, '#5/1/0.5/30');

window.location.hash = '#4/wrongly/formed/hash';

t.false(hash._onHashChange());
Expand Down

0 comments on commit 164f7ba

Please sign in to comment.