Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removed use of bind

  • Loading branch information...
commit 3c7304b03b8f4bca9c7becde0b8f473e084c02d4 1 parent 3355146
@twobit authored
Showing with 6 additions and 48 deletions.
  1. +6 −48 parallaxer.js
View
54 parallaxer.js
@@ -11,13 +11,15 @@
this._transitioning = false;
this._lastCursor = null;
+ var self = this;
+
if (window.DeviceMotionEvent) {
this._ax = this._ay = 0.0;
setInterval(this._onDeviceMotionRender.bind(this));
- window.addEventListener('devicemotion', this._onDeviceMotion.bind(this), true);
+ window.addEventListener('devicemotion', function(e) {self._onDeviceMotion(e);}, true);
}
else {
- window.addEventListener('mousemove', this._onMouseMove.bind(this), true);
+ window.addEventListener('mousemove', function(e) {self._onMouseMove(e);}, true);
}
}
@@ -55,7 +57,8 @@
_transition: function() {
this._transitioning = true;
this._stage.style.WebkitTransition = Parallaxer.TRANSITION;
- window.addEventListener('webkitTransitionEnd', this._onEndTransition.bind(this), true);
+ var self = this;
+ window.addEventListener('webkitTransitionEnd', function(e) {self._onEndTransition(e);}, true);
},
_onEndTransition: function() {
@@ -85,50 +88,5 @@
}
};
- // Taken from ES5-shim https://github.com/kriskowal/es5-shim/blob/master/es5-shim.js
- // ES-5 15.3.4.5
- // http://es5.github.com/#x15.3.4.5
- if (!Function.prototype.bind) {
- Function.prototype.bind = function bind(that) {
-
- var target = this;
-
- if (typeof target != "function") {
- throw new TypeError();
- }
-
- var args = Array.prototype.slice.call(arguments, 1),
- bound = function () {
-
- if (this instanceof bound) {
-
- var F = function(){};
- F.prototype = target.prototype;
- var self = new F();
-
- var result = target.apply(
- self,
- args.concat(Array.prototype.slice.call(arguments))
- );
- if (Object(result) === result) {
- return result;
- }
- return self;
-
- } else {
-
- return target.apply(
- that,
- args.concat(Array.prototype.slice.call(arguments))
- );
-
- }
-
- };
-
- return bound;
- };
- }
-
window.Parallaxer = Parallaxer;
})(window);
Please sign in to comment.
Something went wrong with that request. Please try again.