scale presentations on ipad instead of zoom
This commit is contained in:
		
							
								
								
									
										116
									
								
								js/reveal.js
									
									
									
									
									
								
							
							
						
						
									
										116
									
								
								js/reveal.js
									
									
									
									
									
								
							@@ -552,78 +552,82 @@ var Reveal = (function(){
 | 
				
			|||||||
	 */
 | 
						 */
 | 
				
			||||||
	function layout() {
 | 
						function layout() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Available space to scale within
 | 
							if( dom.wrapper ) {
 | 
				
			||||||
		var availableWidth = dom.wrapper.offsetWidth,
 | 
					 | 
				
			||||||
			availableHeight = dom.wrapper.offsetHeight;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Reduce availabe space by margin
 | 
								// Available space to scale within
 | 
				
			||||||
		availableWidth -= ( availableHeight * config.margin );
 | 
								var availableWidth = dom.wrapper.offsetWidth,
 | 
				
			||||||
		availableHeight -= ( availableHeight * config.margin );
 | 
									availableHeight = dom.wrapper.offsetHeight;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Dimensions of the content
 | 
								// Reduce availabe space by margin
 | 
				
			||||||
		var slideWidth = config.width,
 | 
								availableWidth -= ( availableHeight * config.margin );
 | 
				
			||||||
			slideHeight = config.height;
 | 
								availableHeight -= ( availableHeight * config.margin );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Slide width may be a percentage of available width
 | 
								// Dimensions of the content
 | 
				
			||||||
		if( typeof slideWidth === 'string' && /%$/.test( slideWidth ) ) {
 | 
								var slideWidth = config.width,
 | 
				
			||||||
			slideWidth = parseInt( slideWidth, 10 ) / 100 * availableWidth;
 | 
									slideHeight = config.height;
 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Slide height may be a percentage of available height
 | 
								// Slide width may be a percentage of available width
 | 
				
			||||||
		if( typeof slideHeight === 'string' && /%$/.test( slideHeight ) ) {
 | 
								if( typeof slideWidth === 'string' && /%$/.test( slideWidth ) ) {
 | 
				
			||||||
			slideHeight = parseInt( slideHeight, 10 ) / 100 * availableHeight;
 | 
									slideWidth = parseInt( slideWidth, 10 ) / 100 * availableWidth;
 | 
				
			||||||
		}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		dom.slides.style.width = slideWidth + 'px';
 | 
								// Slide height may be a percentage of available height
 | 
				
			||||||
		dom.slides.style.height = slideHeight + 'px';
 | 
								if( typeof slideHeight === 'string' && /%$/.test( slideHeight ) ) {
 | 
				
			||||||
 | 
									slideHeight = parseInt( slideHeight, 10 ) / 100 * availableHeight;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Determine scale of content to fit within available space
 | 
								dom.slides.style.width = slideWidth + 'px';
 | 
				
			||||||
		scale = Math.min( availableWidth / slideWidth, availableHeight / slideHeight );
 | 
								dom.slides.style.height = slideHeight + 'px';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Respect max/min scale settings
 | 
								// Determine scale of content to fit within available space
 | 
				
			||||||
		scale = Math.max( scale, config.minScale );
 | 
								scale = Math.min( availableWidth / slideWidth, availableHeight / slideHeight );
 | 
				
			||||||
		scale = Math.min( scale, config.maxScale );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Prefer applying scale via zoom since Chrome blurs scaled content
 | 
								// Respect max/min scale settings
 | 
				
			||||||
		// with nested transforms
 | 
								scale = Math.max( scale, config.minScale );
 | 
				
			||||||
		if( typeof dom.slides.style.zoom !== 'undefined' && !navigator.userAgent.match( /(iphone|ipod|android)/gi ) ) {
 | 
								scale = Math.min( scale, config.maxScale );
 | 
				
			||||||
			dom.slides.style.zoom = scale;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		// Apply scale transform as a fallback
 | 
					 | 
				
			||||||
		else {
 | 
					 | 
				
			||||||
			var transform = 'translate(-50%, -50%) scale('+ scale +') translate(50%, 50%)';
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			dom.slides.style.WebkitTransform = transform;
 | 
								// Prefer applying scale via zoom since Chrome blurs scaled content
 | 
				
			||||||
			dom.slides.style.MozTransform = transform;
 | 
								// with nested transforms
 | 
				
			||||||
			dom.slides.style.msTransform = transform;
 | 
								if( typeof dom.slides.style.zoom !== 'undefined' && !navigator.userAgent.match( /(iphone|ipod|ipad|android)/gi ) ) {
 | 
				
			||||||
			dom.slides.style.OTransform = transform;
 | 
									dom.slides.style.zoom = scale;
 | 
				
			||||||
			dom.slides.style.transform = transform;
 | 
								}
 | 
				
			||||||
		}
 | 
								// Apply scale transform as a fallback
 | 
				
			||||||
 | 
								else {
 | 
				
			||||||
 | 
									var transform = 'translate(-50%, -50%) scale('+ scale +') translate(50%, 50%)';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if( config.center ) {
 | 
									dom.slides.style.WebkitTransform = transform;
 | 
				
			||||||
 | 
									dom.slides.style.MozTransform = transform;
 | 
				
			||||||
 | 
									dom.slides.style.msTransform = transform;
 | 
				
			||||||
 | 
									dom.slides.style.OTransform = transform;
 | 
				
			||||||
 | 
									dom.slides.style.transform = transform;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// Select all slides, vertical and horizontal
 | 
								if( config.center ) {
 | 
				
			||||||
			var slides = toArray( document.querySelectorAll( SLIDES_SELECTOR ) );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// Determine the minimum top offset for slides
 | 
									// Select all slides, vertical and horizontal
 | 
				
			||||||
			var minTop = -slideHeight / 2;
 | 
									var slides = toArray( document.querySelectorAll( SLIDES_SELECTOR ) );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			for( var i = 0, len = slides.length; i < len; i++ ) {
 | 
									// Determine the minimum top offset for slides
 | 
				
			||||||
				var slide = slides[ i ];
 | 
									var minTop = -slideHeight / 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				// Don't bother updating invisible slides
 | 
									for( var i = 0, len = slides.length; i < len; i++ ) {
 | 
				
			||||||
				if( slide.style.display === 'none' ) {
 | 
										var slide = slides[ i ];
 | 
				
			||||||
					continue;
 | 
					
 | 
				
			||||||
 | 
										// Don't bother updating invisible slides
 | 
				
			||||||
 | 
										if( slide.style.display === 'none' ) {
 | 
				
			||||||
 | 
											continue;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										// Vertical stacks are not centered since their section
 | 
				
			||||||
 | 
										// children will be
 | 
				
			||||||
 | 
										if( slide.classList.contains( 'stack' ) ) {
 | 
				
			||||||
 | 
											slide.style.top = 0;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										else {
 | 
				
			||||||
 | 
											slide.style.top = Math.max( - ( slide.offsetHeight / 2 ) - 20, minTop ) + 'px';
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				// Vertical stacks are not centered since their section
 | 
					 | 
				
			||||||
				// children will be
 | 
					 | 
				
			||||||
				if( slide.classList.contains( 'stack' ) ) {
 | 
					 | 
				
			||||||
					slide.style.top = 0;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				else {
 | 
					 | 
				
			||||||
					slide.style.top = Math.max( - ( slide.offsetHeight / 2 ) - 20, minTop ) + 'px';
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								js/reveal.min.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								js/reveal.min.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Reference in New Issue
	
	Block a user