Skip to content
This repository has been archived by the owner on Nov 12, 2017. It is now read-only.

Commit

Permalink
throw error if bind / unbind is called when already bound/unbound
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaëtan Renaudeau committed Nov 28, 2013
1 parent 43c85e8 commit 76a8c9b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/swipeview.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

SwipeView.prototype = {
bind: function () {
if (this._bound) throw new Error("SwipeView was already bounded");
this._bound = true;
on(window, resizeEvent, this.handleEventF, false);
on(this.wrapper, startEvent, this.handleEventF, false);
on(this.wrapper, moveEvent, this.handleEventF, false);
Expand All @@ -255,6 +257,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
},

unbind : function(){
if (!this._bound) throw new Error("SwipeView was not bounded");
this._bound = false;
// Remove the event listeners
off(window, resizeEvent, this.handleEventF);
off(this.wrapper, startEvent, this.handleEventF);
Expand Down

0 comments on commit 76a8c9b

Please sign in to comment.