Переглянути джерело

Add ability to prevent swipe for specific elements

Calyhre 10 роки тому
батько
коміт
4e70cf8126
1 змінених файлів з 13 додано та 0 видалено
  1. 13 0
      js/reveal.js

+ 13 - 0
js/reveal.js

@@ -3482,6 +3482,8 @@
 	 */
 	function onTouchStart( event ) {
 
+		if(preventSwipe(event.target)) return true;
+
 		touch.startX = event.touches[0].clientX;
 		touch.startY = event.touches[0].clientY;
 		touch.startCount = event.touches.length;
@@ -3505,6 +3507,8 @@
 	 */
 	function onTouchMove( event ) {
 
+		if(preventSwipe(event.target)) return true;
+
 		// Each touch should only trigger one action
 		if( !touch.captured ) {
 			onUserInput( event );
@@ -3786,6 +3790,15 @@
 
 	}
 
+	function preventSwipe(target) {
+		while( target && typeof target.hasAttribute == 'function' ) {
+			if(target.hasAttribute('prevent-swipe')) return true;
+			target = target.parentNode;
+		}
+
+		return false;
+	}
+
 
 	// --------------------------------------------------------------------//
 	// ------------------------ PLAYBACK COMPONENT ------------------------//