Permalink
Browse files

apply passive options to fix chrome54+ bugs

ref #1119
1 parent 0c6135e commit 0788ab94e240494734bffd3a7102048942537bba @sculove sculove committed Dec 29, 2016
@@ -7,7 +7,7 @@
<title>iScroll demo: 2d scroll</title>
<script type="text/javascript" src="../../build/iscroll.js"></script>
-
+<script type="text/javascript" src="../demoUtils.js"></script>
<script type="text/javascript">
var myScroll;
@@ -16,7 +16,10 @@
myScroll = new IScroll('#wrapper', { scrollX: true, freeScroll: true });
}
-document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
+ capture: false,
+ passive: false
+} : false);
</script>
@@ -7,7 +7,7 @@
<title>iScroll demo: barebone</title>
<script type="text/javascript" src="../../build/iscroll.js"></script>
-
+<script type="text/javascript" src="../demoUtils.js"></script>
<script type="text/javascript">
var myScroll;
@@ -16,7 +16,10 @@
myScroll = new IScroll('#wrapper');
}
-document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
+ capture: false,
+ passive: false
+} : false);
</script>
@@ -7,7 +7,7 @@
<title>iScroll demo: bounce easing</title>
<script type="text/javascript" src="../../build/iscroll.js"></script>
-
+<script type="text/javascript" src="../demoUtils.js"></script>
<script type="text/javascript">
var myScroll;
@@ -16,7 +16,10 @@
myScroll = new IScroll('#wrapper', { bounceEasing: 'elastic', bounceTime: 1200 });
}
-document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
+ capture: false,
+ passive: false
+} : false);
</script>
@@ -7,7 +7,7 @@
<title>iScroll demo: carousel</title>
<script type="text/javascript" src="../../build/iscroll.js"></script>
-
+<script type="text/javascript" src="../demoUtils.js"></script>
<script type="text/javascript">
var myScroll;
@@ -27,7 +27,10 @@
});
}
-document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
+ capture: false,
+ passive: false
+} : false);
</script>
<style type="text/css">
@@ -7,7 +7,7 @@
<title>iScroll demo: click</title>
<script type="text/javascript" src="../../build/iscroll.js"></script>
-
+<script type="text/javascript" src="../demoUtils.js"></script>
<script type="text/javascript">
var myScroll;
@@ -16,7 +16,10 @@
myScroll = new IScroll('#wrapper', { mouseWheel: true, click: true });
}
-document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
+ capture: false,
+ passive: false
+} : false);
</script>
View
@@ -0,0 +1,13 @@
+// https://github.com/WICG/EventListenerOptions/pull/30
+function isPassive() {
+ var supportsCaptureOption = false;
+ try {
+ addEventListener("test", null, Object.defineProperty({}, 'capture', {
+ get: function () {
+ supportsCaptureOption = true;
+ }
+ }));
+ } catch(e) {}
+ return supportsCaptureOption;
+}
+
@@ -7,7 +7,7 @@
<title>iScroll demo: simple</title>
<script type="text/javascript" src="../../build/iscroll.js"></script>
-
+<script type="text/javascript" src="../demoUtils.js"></script>
<script type="text/javascript">
var myScroll;
@@ -16,7 +16,10 @@
myScroll = new IScroll('#wrapper', { mouseWheel: true });
}
-document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
+ capture: false,
+ passive: false
+} : false);
</script>
@@ -7,7 +7,7 @@
<title>iScroll demo: horizontal scrolling</title>
<script type="text/javascript" src="../../build/iscroll.js"></script>
-
+<script type="text/javascript" src="../demoUtils.js"></script>
<script type="text/javascript">
var myScroll;
@@ -16,7 +16,10 @@
myScroll = new IScroll('#wrapper', { scrollX: true, scrollY: false, mouseWheel: true });
}
-document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
+ capture: false,
+ passive: false
+} : false);
</script>
@@ -7,7 +7,7 @@
<title>iScroll demo: infinite scrolling</title>
<script type="text/javascript" src="../../build/iscroll-infinite.js"></script>
-
+<script type="text/javascript" src="../demoUtils.js"></script>
<script type="text/javascript">
/******************************************************************************
*
@@ -82,7 +82,10 @@
el.innerHTML = data;
}
-document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
+ capture: false,
+ passive: false
+} : false);
</script>
@@ -7,7 +7,7 @@
<title>iScroll demo: key bindings</title>
<script type="text/javascript" src="../../build/iscroll.js"></script>
-
+<script type="text/javascript" src="../demoUtils.js"></script>
<script type="text/javascript">
var myScroll;
@@ -16,7 +16,10 @@
myScroll = new IScroll('#wrapper', { keyBindings: true });
}
-document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
+ capture: false,
+ passive: false
+} : false);
</script>
@@ -7,7 +7,7 @@
<title>iScroll demo: minimap</title>
<script type="text/javascript" src="../../build/iscroll.js"></script>
-
+<!--<script type="text/javascript" src="../demoUtils.js"></script>-->
<script type="text/javascript">
var myScroll;
@@ -27,7 +27,10 @@
});
}
-//document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+// document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
+// capture: false,
+// passive: false
+// } : false);
</script>
@@ -7,7 +7,7 @@
<title>iScroll demo: No transition</title>
<script type="text/javascript" src="../../build/iscroll.js"></script>
-
+<script type="text/javascript" src="../demoUtils.js"></script>
<script type="text/javascript">
var myScroll;
@@ -16,7 +16,10 @@
myScroll = new IScroll('#wrapper', { useTransition: false });
}
-document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
+ capture: false,
+ passive: false
+} : false);
</script>
@@ -7,7 +7,7 @@
<title>iScroll demo: starfield</title>
<script type="text/javascript" src="../../build/iscroll.js"></script>
-
+<script type="text/javascript" src="../demoUtils.js"></script>
<script type="text/javascript">
var myScroll;
@@ -29,7 +29,10 @@
});
}
-document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
+ capture: false,
+ passive: false
+} : false);
</script>
@@ -7,7 +7,7 @@
<title>iScroll demo: probe</title>
<script type="text/javascript" src="../../build/iscroll-probe.js"></script>
-
+<script type="text/javascript" src="../demoUtils.js"></script>
<script type="text/javascript">
var myScroll;
@@ -26,7 +26,10 @@
myScroll.on('scrollEnd', updatePosition);
}
-document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
+ capture: false,
+ passive: false
+} : false);
</script>
@@ -7,7 +7,7 @@
<title>iScroll demo: scroll to element</title>
<script type="text/javascript" src="../../build/iscroll.js"></script>
-
+<script type="text/javascript" src="../demoUtils.js"></script>
<script type="text/javascript">
var myScroll;
@@ -16,7 +16,10 @@
myScroll = new IScroll('#wrapper', { mouseWheel: true, click: true });
}
-document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
+ capture: false,
+ passive: false
+} : false);
</script>
@@ -7,7 +7,7 @@
<title>iScroll demo: scrollbars</title>
<script type="text/javascript" src="../../build/iscroll.js"></script>
-
+<script type="text/javascript" src="../demoUtils.js"></script>
<script type="text/javascript">
var myScroll;
@@ -22,7 +22,10 @@
});
}
-document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
+ capture: false,
+ passive: false
+} : false);
</script>
@@ -7,7 +7,7 @@
<title>iScroll demo: simple</title>
<script type="text/javascript" src="../../build/iscroll.js"></script>
-
+<script type="text/javascript" src="../demoUtils.js"></script>
<script type="text/javascript">
var myScroll;
@@ -16,7 +16,10 @@
myScroll = new IScroll('#wrapper', { mouseWheel: true });
}
-document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
+ capture: false,
+ passive: false
+} : false);
</script>
@@ -7,7 +7,7 @@
<title>iScroll demo: snap</title>
<script type="text/javascript" src="../../build/iscroll.js"></script>
-
+<script type="text/javascript" src="../demoUtils.js"></script>
<script type="text/javascript">
var myScroll;
@@ -21,7 +21,10 @@
});
}
-document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
+ capture: false,
+ passive: false
+} : false);
</script>
<style type="text/css">
@@ -7,7 +7,7 @@
<title>iScroll demo: styled scrollbars</title>
<script type="text/javascript" src="../../build/iscroll.js"></script>
-
+<script type="text/javascript" src="../demoUtils.js"></script>
<script type="text/javascript">
var myScroll;
@@ -16,7 +16,10 @@
myScroll = new IScroll('#wrapper', { scrollX: true, scrollbars: 'custom' });
}
-document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
+ capture: false,
+ passive: false
+} : false);
</script>
Oops, something went wrong.

0 comments on commit 0788ab9

Please sign in to comment.