UNPKG

imageviewer_terrydr

Version:

A simple jQuery image viewing plugin.

52 lines (38 loc) 1.46 kB
bind: function () { var options = this.options; var $this = this.$element; if ($.isFunction(options.view)) { $this.on(EVENT_VIEW, options.view); } if ($.isFunction(options.viewed)) { $this.on(EVENT_VIEWED, options.viewed); } this.$viewer. on(EVENT_CLICK, $.proxy(this.click, this)). on(EVENT_WHEEL, $.proxy(this.wheel, this)); this.$canvas.on(EVENT_MOUSEDOWN, $.proxy(this.mousedown, this)); $document. on(EVENT_MOUSEMOVE, (this._mousemove = proxy(this.mousemove, this))). on(EVENT_MOUSEUP, (this._mouseup = proxy(this.mouseup, this))). on(EVENT_KEYDOWN, (this._keydown = proxy(this.keydown, this))); $window.on(EVENT_RESIZE, (this._resize = proxy(this.resize, this))); }, unbind: function () { var options = this.options; var $this = this.$element; if ($.isFunction(options.view)) { $this.off(EVENT_VIEW, options.view); } if ($.isFunction(options.viewed)) { $this.off(EVENT_VIEWED, options.viewed); } this.$viewer. off(EVENT_CLICK, this.click). off(EVENT_WHEEL, this.wheel); this.$canvas.off(EVENT_MOUSEDOWN, this.mousedown); $document. off(EVENT_MOUSEMOVE, this._mousemove). off(EVENT_MOUSEUP, this._mouseup). off(EVENT_KEYDOWN, this._keydown); $window.off(EVENT_RESIZE, this._resize); },