Merge pull request #6675 from tchandelle/translate-cursor

Reset cursor when translate interaction is removed or deactivated
This commit is contained in:
Tim Schaub
2017-04-13 20:25:20 -06:00
committed by GitHub
2 changed files with 99 additions and 0 deletions

View File

@@ -224,11 +224,67 @@ describe('ol.interaction.Translate', function() {
simulateEvent('pointerup', 10, 20);
expect(element.style.cursor).to.match(/grab$/);
simulateEvent('pointermove', 0, 0);
expect(element.style.cursor).to.eql('');
});
it('respects existing cursor value', function() {
element.style.cursor = 'pointer';
simulateEvent('pointermove', 10, 20);
expect(element.style.cursor).to.match(/grab$/);
simulateEvent('pointerdown', 10, 20);
expect(element.style.cursor).to.match(/grabbing$/);
simulateEvent('pointerup', 10, 20);
expect(element.style.cursor).to.match(/grab$/);
simulateEvent('pointermove', 0, 0);
expect(element.style.cursor).to.eql('pointer');
});
it('resets css cursor when interaction is deactivated while pointer is on feature', function() {
simulateEvent('pointermove', 10, 20);
expect(element.style.cursor).to.match(/grab$/);
translate.setActive(false);
simulateEvent('pointermove', 0, 0);
expect(element.style.cursor).to.eql('');
});
it('resets css cursor to existing cursor when interaction is deactivated while pointer is on feature', function() {
element.style.cursor = 'pointer';
simulateEvent('pointermove', 10, 20);
expect(element.style.cursor).to.match(/grab$/);
translate.setActive(false);
simulateEvent('pointermove', 0, 0);
expect(element.style.cursor).to.eql('pointer');
});
it('resets css cursor interaction is removed while pointer is on feature', function() {
simulateEvent('pointermove', 10, 20);
expect(element.style.cursor).to.match(/grab$/);
map.removeInteraction(translate);
simulateEvent('pointermove', 0, 0);
expect(element.style.cursor).to.eql('');
});
it('resets css cursor to existing cursor interaction is removed while pointer is on feature', function() {
element.style.cursor = 'pointer';
simulateEvent('pointermove', 10, 20);
expect(element.style.cursor).to.match(/grab$/);
map.removeInteraction(translate);
simulateEvent('pointermove', 0, 0);
expect(element.style.cursor).to.eql('pointer');
});