Skip to content

Commit

Permalink
fix(carousel): Correct dragging on ios
Browse files Browse the repository at this point in the history
  • Loading branch information
leifoolsen committed May 28, 2016
1 parent 02eee86 commit 4f900c3
Show file tree
Hide file tree
Showing 23 changed files with 59 additions and 55 deletions.
4 changes: 2 additions & 2 deletions demo/accordion.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="styles/dialog-polyfill.css">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.indigo-pink.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.css">
<link rel="stylesheet" href="./styles/demo.css">

<title>Material Design Lite Extensions - Accordion</title>
Expand Down Expand Up @@ -811,7 +811,7 @@ <h5>Fifth</h5>
<script src="scripts/dialog-polyfill.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/eq-customevent-patch.js" type="text/javascript" charset="utf-8"></script>
<script src="https://code.getmdl.io/1.1.3/material.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.js" type="text/javascript" charset="utf-8"></script>


<script>
Expand Down
4 changes: 2 additions & 2 deletions demo/bordered-fields.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="styles/dialog-polyfill.css">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.indigo-pink.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.css">
<link rel="stylesheet" href="./styles/demo.css">

<title>Material Design Lite Extensions - Bordered Fields</title>
Expand Down Expand Up @@ -484,7 +484,7 @@ <h5>Credits</h5>
<script src="scripts/dialog-polyfill.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/eq-customevent-patch.js" type="text/javascript" charset="utf-8"></script>
<script src="https://code.getmdl.io/1.1.3/material.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.js" type="text/javascript" charset="utf-8"></script>

<script>
(function() {
Expand Down
6 changes: 3 additions & 3 deletions demo/carousel.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="styles/dialog-polyfill.css">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.indigo-pink.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.css">
<link rel="stylesheet" href="./styles/demo.css">

<title>Material Design Lite Extensions - Carousel</title>
Expand Down Expand Up @@ -638,7 +638,7 @@ <h5>Carousel</h5>


<div style="margin-top: 8px">
<button id="btn-add-image" class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored">
<button id="btn-add-image" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--raised mdl-button--colored">
Add image to carousel
</button>
<p class="mdl-typography--caption" style="margin-top: 8px">
Expand Down Expand Up @@ -744,7 +744,7 @@ <h5>Carousel</h5>
<script src="scripts/dialog-polyfill.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/eq-customevent-patch.js" type="text/javascript" charset="utf-8"></script>
<script src="https://code.getmdl.io/1.1.3/material.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.js" type="text/javascript" charset="utf-8"></script>

<script>
(function() {
Expand Down
4 changes: 2 additions & 2 deletions demo/color-themes.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="styles/dialog-polyfill.css">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.indigo-pink.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.css">
<link rel="stylesheet" href="./styles/demo.css">

<title>Material Design Lite Extensions - Color Themes</title>
Expand Down Expand Up @@ -2702,7 +2702,7 @@ <h6>h6 (16px) <small>Subtitle</small></h6>
<script src="scripts/dialog-polyfill.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/eq-customevent-patch.js" type="text/javascript" charset="utf-8"></script>
<script src="https://code.getmdl.io/1.1.3/material.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.js" type="text/javascript" charset="utf-8"></script>

<script>
(function() {
Expand Down
4 changes: 2 additions & 2 deletions demo/grid.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="styles/dialog-polyfill.css">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.indigo-pink.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.css">
<link rel="stylesheet" href="./styles/demo.css">

<title>Material Design Lite Extensions - Grid</title>
Expand Down Expand Up @@ -262,7 +262,7 @@ <h5>mdl-grid, using media queries</h5>
<script src="scripts/dialog-polyfill.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/eq-customevent-patch.js" type="text/javascript" charset="utf-8"></script>
<script src="https://code.getmdl.io/1.1.3/material.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.js" type="text/javascript" charset="utf-8"></script>

<script>
(function() {
Expand Down
4 changes: 2 additions & 2 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="styles/dialog-polyfill.css">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.indigo-pink.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.css">
<link rel="stylesheet" href="./styles/demo.css">

<title>Material Design Lite Extensions</title>
Expand Down Expand Up @@ -186,7 +186,7 @@ <h4>Sticky Header</h4>
<script src="scripts/dialog-polyfill.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/eq-customevent-patch.js" type="text/javascript" charset="utf-8"></script>
<script src="https://code.getmdl.io/1.1.3/material.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.js" type="text/javascript" charset="utf-8"></script>

<script>
(function() {
Expand Down
4 changes: 2 additions & 2 deletions demo/lightboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="styles/dialog-polyfill.css">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.indigo-pink.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.css">
<link rel="stylesheet" href="./styles/demo.css">

<title>Material Design Lite Extensions - Lightboard</title>
Expand Down Expand Up @@ -314,7 +314,7 @@ <h5 class="mdlext-demo-header">Lightboard Component</h5>
<script src="scripts/dialog-polyfill.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/eq-customevent-patch.js" type="text/javascript" charset="utf-8"></script>
<script src="https://code.getmdl.io/1.1.3/material.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.js" type="text/javascript" charset="utf-8"></script>

<script>
(function() {
Expand Down
4 changes: 2 additions & 2 deletions demo/lightbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="styles/dialog-polyfill.css">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.indigo-pink.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.css">
<link rel="stylesheet" href="./styles/demo.css">

<title>Material Design Lite Extensions - Lightbox</title>
Expand Down Expand Up @@ -693,7 +693,7 @@ <h5 class="mdlext-demo-header">Lightbox Component</h5>
<script src="scripts/dialog-polyfill.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/eq-customevent-patch.js" type="text/javascript" charset="utf-8"></script>
<script src="https://code.getmdl.io/1.1.3/material.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.js" type="text/javascript" charset="utf-8"></script>

<script>
(function() {
Expand Down
4 changes: 2 additions & 2 deletions demo/selectfield.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="styles/dialog-polyfill.css">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.indigo-pink.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.css">
<link rel="stylesheet" href="./styles/demo.css">

<title>Material Design Lite Extensions - Selectfield</title>
Expand Down Expand Up @@ -253,7 +253,7 @@ <h5 class="mdlext-demo-header">Selectfield Component</h5>
<script src="scripts/dialog-polyfill.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/eq-customevent-patch.js" type="text/javascript" charset="utf-8"></script>
<script src="https://code.getmdl.io/1.1.3/material.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.js" type="text/javascript" charset="utf-8"></script>

<script>
(function() {
Expand Down
4 changes: 2 additions & 2 deletions demo/sticky-header-ii.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="styles/dialog-polyfill.css">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.indigo-pink.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.css">
<link rel="stylesheet" href="./styles/demo.css">

<title>Material Design Lite Extensions - Sticky Header</title>
Expand Down Expand Up @@ -152,7 +152,7 @@ <h5>Sticky Header, Drawer (not fixed)</h5>
<script src="scripts/dialog-polyfill.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/eq-customevent-patch.js" type="text/javascript" charset="utf-8"></script>
<script src="https://code.getmdl.io/1.1.3/material.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.js" type="text/javascript" charset="utf-8"></script>

<script>
(function() {
Expand Down
4 changes: 2 additions & 2 deletions demo/sticky-header-iii.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="styles/dialog-polyfill.css">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.indigo-pink.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.css">
<link rel="stylesheet" href="./styles/demo.css">

<title>Material Design Lite Extensions - Sticky Header</title>
Expand Down Expand Up @@ -66,7 +66,7 @@ <h5>Sticky Header, No Drawer</h5>
<script src="scripts/dialog-polyfill.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/eq-customevent-patch.js" type="text/javascript" charset="utf-8"></script>
<script src="https://code.getmdl.io/1.1.3/material.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.js" type="text/javascript" charset="utf-8"></script>

<script>
(function() {
Expand Down
4 changes: 2 additions & 2 deletions demo/sticky-header-iv.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="styles/dialog-polyfill.css">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.indigo-pink.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.css">
<link rel="stylesheet" href="./styles/demo.css">

<title>Material Design Lite Extensions - Sticky Header</title>
Expand Down Expand Up @@ -162,7 +162,7 @@ <h5>Sticky Header, Waterfall, Fixed Drawer</h5>
<script src="scripts/dialog-polyfill.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/eq-customevent-patch.js" type="text/javascript" charset="utf-8"></script>
<script src="https://code.getmdl.io/1.1.3/material.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.js" type="text/javascript" charset="utf-8"></script>

<script>
(function() {
Expand Down
4 changes: 2 additions & 2 deletions demo/sticky-header-v.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="styles/dialog-polyfill.css">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.indigo-pink.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.css">
<link rel="stylesheet" href="./styles/demo.css">

<title>Material Design Lite Extensions - Sticky Header</title>
Expand Down Expand Up @@ -162,7 +162,7 @@ <h5>Sticky Header, Waterfall, Drawer (not fixed)</h5>
<script src="scripts/dialog-polyfill.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/eq-customevent-patch.js" type="text/javascript" charset="utf-8"></script>
<script src="https://code.getmdl.io/1.1.3/material.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.js" type="text/javascript" charset="utf-8"></script>

<script>
(function() {
Expand Down
4 changes: 2 additions & 2 deletions demo/sticky-header-vi.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="styles/dialog-polyfill.css">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.indigo-pink.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.css">
<link rel="stylesheet" href="./styles/demo.css">

<title>Material Design Lite Extensions - Sticky Header</title>
Expand Down Expand Up @@ -75,7 +75,7 @@ <h5>Sticky Header, Waterfall, No Drawer</h5>
<script src="scripts/dialog-polyfill.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/eq-customevent-patch.js" type="text/javascript" charset="utf-8"></script>
<script src="https://code.getmdl.io/1.1.3/material.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.js" type="text/javascript" charset="utf-8"></script>

<script>
(function() {
Expand Down
4 changes: 2 additions & 2 deletions demo/sticky-header.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="styles/dialog-polyfill.css">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.indigo-pink.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.css">
<link rel="stylesheet" href="./styles/demo.css">

<title>Material Design Lite Extensions - Sticky Header</title>
Expand Down Expand Up @@ -150,7 +150,7 @@ <h5>Sticky Header, Fixed Drawer Example</h5>
<script src="scripts/dialog-polyfill.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/eq-customevent-patch.js" type="text/javascript" charset="utf-8"></script>
<script src="https://code.getmdl.io/1.1.3/material.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.js" type="text/javascript" charset="utf-8"></script>

<script>
(function() {
Expand Down
21 changes: 11 additions & 10 deletions lib/mdl-ext.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/mdl-ext.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/mdl-ext.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/mdl-ext.min.js.map

Large diffs are not rendered by default.

19 changes: 11 additions & 8 deletions src/carousel/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,9 @@ import { inOutQuintic } from '../utils/easing';
// Cancel slideshow if running
this.cancelSlideShow_();

let updating = false;
let rAFDragId = 0;
//let updating = false;
//let rAFDragId = 0;

const startX = event.clientX || (event.touches !== undefined ? event.touches[0].clientX : 0);
let prevX = startX;
const targetElement = event.target;
Expand All @@ -359,16 +360,18 @@ import { inOutQuintic } from '../utils/easing';
}

prevX = currentX;
updating = false;
//updating = false;
};

// drag handler
const drag = e => {
e.preventDefault();
if(!updating) {
rAFDragId = window.requestAnimationFrame( () => update(e));
updating = true;
}
update(e);

//if(!updating) {
// rAFDragId = window.requestAnimationFrame( () => update(e));
// updating = true;
//}
};

// end drag handler
Expand All @@ -382,7 +385,7 @@ import { inOutQuintic } from '../utils/easing';
window.removeEventListener('touchend', endDrag);

// cancel any existing drag rAF, see: http://www.html5rocks.com/en/tutorials/speed/animations/
window.cancelAnimationFrame(rAFDragId);
//window.cancelAnimationFrame(rAFDragId);

// If mouse did not move, trigger custom select event
if(Math.abs(startX-x) < 2) {
Expand Down
2 changes: 1 addition & 1 deletion src/carousel/snippets/carousel.html
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ <h5>Carousel</h5>


<div style="margin-top: 8px">
<button id="btn-add-image" class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored">
<button id="btn-add-image" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--raised mdl-button--colored">
Add image to carousel
</button>
<p class="mdl-typography--caption" style="margin-top: 8px">
Expand Down
2 changes: 1 addition & 1 deletion src/demo/include/_head.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="styles/dialog-polyfill.css">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.indigo-pink.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.min.css">
<link rel="stylesheet" href="../lib/mdl-ext-eqjs.css">
<link rel="stylesheet" href="./styles/demo.css">
2 changes: 1 addition & 1 deletion src/demo/include/_scripts.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script src="scripts/dialog-polyfill.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/eq-customevent-patch.js" type="text/javascript" charset="utf-8"></script>
<script src="https://code.getmdl.io/1.1.3/material.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../lib/mdl-ext.js" type="text/javascript" charset="utf-8"></script>

0 comments on commit 4f900c3

Please sign in to comment.