diff --git a/src/Global.js b/src/Global.js index d9d1e984..3877c440 100644 --- a/src/Global.js +++ b/src/Global.js @@ -135,22 +135,6 @@ var Kinetic = {}; } } }; - - // bind() shim for older browsers - if (!Function.prototype.bind) { - Function.prototype.bind = function (oThis) { - var aArgs = Array.prototype.slice.call(arguments, 1), - fToBind = this, - fNOP = function () {}, - fBound = function () { - return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, - aArgs.concat(Array.prototype.slice.call(arguments))); - }; - fNOP.prototype = this.prototype; - fBound.prototype = new fNOP(); - return fBound; - }; - } })(); // Uses Node, AMD or browser globals to create a module. diff --git a/src/Stage.js b/src/Stage.js index 126aaadf..0e167bfe 100644 --- a/src/Stage.js +++ b/src/Stage.js @@ -28,6 +28,12 @@ // cached variables eventsLength = EVENTS.length; + + function addEvent(ctx, eventName) { + ctx.content.addEventListener(eventName, function(evt) { + ctx['_' + eventName](evt); + }, false); + } /** * Stage constructor. A stage is used to contain multiple layers @@ -352,12 +358,10 @@ */ _bindContentEvents: function() { var that = this, - n, pubEvent, f; + n; for (n = 0; n < eventsLength; n++) { - pubEvent = EVENTS[n]; - f = that['_' + pubEvent]; - that.content.addEventListener(pubEvent, f.bind(that), false); + addEvent(this, EVENTS[n]); } }, _mouseout: function(evt) {