Permalink
Browse files

fixed some IE8 issues with unsupported functions, thanks @pmpinto

  • Loading branch information...
1 parent 6946a1c commit ec15feee4ddb8be74ffaa83c593851f32986fe10 Brad Birdsall committed Nov 16, 2011
Showing with 17 additions and 12 deletions.
  1. +16 −11 swipe.js
  2. +1 −1 swipe.min.js
View
@@ -35,14 +35,16 @@ window.Swipe = function(element, options) {
this.start();
// add event listeners
- this.element.addEventListener('touchstart', this, false);
- this.element.addEventListener('touchmove', this, false);
- this.element.addEventListener('touchend', this, false);
- this.element.addEventListener('webkitTransitionEnd', this, false);
- this.element.addEventListener('msTransitionEnd', this, false);
- this.element.addEventListener('oTransitionEnd', this, false);
- this.element.addEventListener('transitionend', this, false);
- window.addEventListener('resize', this, false);
+ if (this.element.addEventListener) {
+ this.element.addEventListener('touchstart', this, false);
+ this.element.addEventListener('touchmove', this, false);
+ this.element.addEventListener('touchend', this, false);
+ this.element.addEventListener('webkitTransitionEnd', this, false);
+ this.element.addEventListener('msTransitionEnd', this, false);
+ this.element.addEventListener('oTransitionEnd', this, false);
+ this.element.addEventListener('transitionend', this, false);
+ window.addEventListener('resize', this, false);
+ }
};
@@ -57,12 +59,15 @@ Swipe.prototype = {
// return immediately if their are less than two slides
if (this.length < 2) return null;
- // hide slider element but keep positioning during setup
- this.container.style.visibility = 'hidden';
-
// determine width of each slide
this.width = this.container.getBoundingClientRect().width;
+ // return immediately if measurement fails
+ if (!this.width) return null;
+
+ // hide slider element but keep positioning during setup
+ this.container.style.visibility = 'hidden';
+
// dynamic css
this.element.style.width = (this.slides.length * this.width) + 'px';
var index = this.slides.length;
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit ec15fee

Please sign in to comment.