Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

Commit

Permalink
Fix handler behavior. Fix type in code docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
kbirk committed Jan 26, 2018
1 parent 097a43b commit c2b3b58
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 36 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

An in-progress version being developed on the `master` branch.

## 0.20.10 - Jan 26th, 2018
### Changed
- No longer throw an exception when enabling an enabled handler, or disabling disabled handler.
- Add package-lock.jon file to repo.

## 0.20.9 - Jan 16th, 2018
### Changed
- Bump dependency versions.
Expand Down
32 changes: 16 additions & 16 deletions build/lumo.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/lumo.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lumo",
"version": "0.20.9",
"version": "0.20.10",
"description": "A high performance WebGL tile rendering library",
"main": "src/exports.js",
"author": "Kevin Birk <[email protected]>",
Expand Down Expand Up @@ -30,11 +30,11 @@
"del": "3.0.0",
"eslint-plugin-jsdoc": "3.3.1",
"gulp": "3.9.1",
"gulp-eslint": "4.0.1",
"gulp-eslint": "4.0.2",
"gulp-istanbul": "1.1.3",
"gulp-mocha": "3.0.1",
"gulp-uglify": "3.0.0",
"sinon": "4.1.6",
"sinon": "4.2.1",
"vinyl-buffer": "1.0.1",
"vinyl-source-stream": "2.0.0"
},
Expand Down
11 changes: 9 additions & 2 deletions src/plot/handler/ClickHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class ClickHandler extends DOMHandler {
* @returns {ClickHandler} The handler object, for chaining.
*/
enable() {
super.enable();
if (this.enabled) {
return this;
}

const plot = this.plot;

Expand Down Expand Up @@ -83,6 +85,7 @@ class ClickHandler extends DOMHandler {
container.addEventListener('mousedown', this.mousedown);
container.addEventListener('mouseup', this.mouseup);
container.addEventListener('dblclick', this.dblclick);
return super.enable();
}

/**
Expand All @@ -91,14 +94,18 @@ class ClickHandler extends DOMHandler {
* @returns {ClickHandler} The handler object, for chaining.
*/
disable() {
super.disable();
if (!this.enabled) {
return this;
}

const container = this.plot.getContainer();
container.removeEventListener('mousedown', this.mousedown);
container.removeEventListener('mouseup', this.mouseup);
container.removeEventListener('dblclick', this.dblclick);
this.mousedown = null;
this.mouseup = null;
this.dblclick = null;
return super.disable();
}
}

Expand Down
12 changes: 4 additions & 8 deletions src/plot/handler/DOMHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,21 @@ class DOMHandler {
/**
* Enables the handler.
*
* @returns {ZoomHandler} The handler object, for chaining.
* @returns {DOMHandler} The handler object, for chaining.
*/
enable() {
if (this.enabled) {
throw 'Handler is already enabled';
}
this.enabled = true;
return this;
}

/**
* Disables the handler.
*
* @returns {ZoomHandler} The handler object, for chaining.
* @returns {DOMHandler} The handler object, for chaining.
*/
disable() {
if (!this.enabled) {
throw 'Handler is already disabled';
}
this.enabled = false;
return this;
}

/**
Expand Down
10 changes: 8 additions & 2 deletions src/plot/handler/MouseHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class MouseHandler extends DOMHandler {
* @returns {MouseHandler} The handler object, for chaining.
*/
enable() {
super.enable();
if (this.enabled) {
return this;
}

const plot = this.plot;

Expand Down Expand Up @@ -81,6 +83,7 @@ class MouseHandler extends DOMHandler {
container.addEventListener('mouseover', this.mouseover);
container.addEventListener('mouseout', this.mouseout);
container.addEventListener('wheel', this.wheel);
return super.enable();
}

/**
Expand All @@ -89,7 +92,9 @@ class MouseHandler extends DOMHandler {
* @returns {MouseHandler} The handler object, for chaining.
*/
disable() {
super.disable();
if (!this.enabled) {
return this;
}

const container = this.plot.getContainer();
container.removeEventListener('mousedown', this.mousedown);
Expand All @@ -104,6 +109,7 @@ class MouseHandler extends DOMHandler {
this.mouseover = null;
this.mouseout = null;
this.wheel = null;
return super.disable();
}
}

Expand Down
10 changes: 8 additions & 2 deletions src/plot/handler/PanHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ class PanHandler extends DOMHandler {
* @returns {PanHandler} The handler object, for chaining.
*/
enable() {
super.enable();
if (this.enabled) {
return this;
}

const plot = this.plot;

Expand Down Expand Up @@ -232,6 +234,7 @@ class PanHandler extends DOMHandler {
container.addEventListener('mousedown', this.mousedown);
document.addEventListener('mousemove', this.mousemove);
document.addEventListener('mouseup', this.mouseup);
return super.enable();
}

/**
Expand All @@ -240,7 +243,9 @@ class PanHandler extends DOMHandler {
* @returns {PanHandler} The handler object, for chaining.
*/
disable() {
super.disable();
if (!this.enabled) {
return this;
}

const container = this.plot.getContainer();
container.removeEventListener('mousedown', this.mousedown);
Expand All @@ -249,6 +254,7 @@ class PanHandler extends DOMHandler {
this.mousedown = null;
this.mousemove = null;
this.mouseup = null;
return super.disable();
}

/**
Expand Down
10 changes: 8 additions & 2 deletions src/plot/handler/ZoomHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ class ZoomHandler extends DOMHandler {
* @returns {ZoomHandler} The handler object, for chaining.
*/
enable() {
super.enable();
if (this.enabled) {
return this;
}

const plot = this.plot;

Expand Down Expand Up @@ -290,6 +292,7 @@ class ZoomHandler extends DOMHandler {
const container = plot.getContainer();
container.addEventListener('dblclick', this.dblclick);
container.addEventListener('wheel', this.wheel);
return super.enable();
}

/**
Expand All @@ -298,13 +301,16 @@ class ZoomHandler extends DOMHandler {
* @returns {ZoomHandler} The handler object, for chaining.
*/
disable() {
super.disable();
if (!this.enabled) {
return this;
}

const container = this.plot.getContainer();
container.removeEventListener('dblclick', this.dblclick);
container.removeEventListener('wheel', this.wheel);
this.dblclick = null;
this.wheel = null;
return super.disable();
}

/**
Expand Down

0 comments on commit c2b3b58

Please sign in to comment.