add util method for applying css transforms
This commit is contained in:
1 parent
b17e285164
commit
6c0dc635a1
2 files changed
+25
-28
No files matched your search
+23
-26
@@ -664,6 +664,19 @@ var Reveal = (function(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies a CSS transform to the target element.
|
||||||
|
*/
|
||||||
|
function transformElement( element, transform ) {
|
||||||
|
|
||||||
|
element.style.WebkitTransform = transform;
|
||||||
|
element.style.MozTransform = transform;
|
||||||
|
element.style.msTransform = transform;
|
||||||
|
element.style.OTransform = transform;
|
||||||
|
element.style.transform = transform;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the height of the given element by looking
|
* Retrieves the height of the given element by looking
|
||||||
* at the position and height of its immediate children.
|
* at the position and height of its immediate children.
|
||||||
@@ -949,13 +962,7 @@ var Reveal = (function(){
|
|||||||
}
|
}
|
||||||
// Apply scale transform as a fallback
|
// Apply scale transform as a fallback
|
||||||
else {
|
else {
|
||||||
var transform = 'translate(-50%, -50%) scale('+ scale +') translate(50%, 50%)';
|
transformElement( dom.slides, 'translate(-50%, -50%) scale('+ scale +') translate(50%, 50%)' );
|
||||||
|
|
||||||
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
|
// Select all slides, vertical and horizontal
|
||||||
@@ -1062,15 +1069,12 @@ var Reveal = (function(){
|
|||||||
|
|
||||||
for( var i = 0, len1 = horizontalSlides.length; i < len1; i++ ) {
|
for( var i = 0, len1 = horizontalSlides.length; i < len1; i++ ) {
|
||||||
var hslide = horizontalSlides[i],
|
var hslide = horizontalSlides[i],
|
||||||
hoffset = config.rtl ? -105 : 105,
|
hoffset = config.rtl ? -105 : 105;
|
||||||
htransform = 'translateZ(-'+ depth +'px) translate(' + ( ( i - indexh ) * hoffset ) + '%, 0%)';
|
|
||||||
|
|
||||||
hslide.setAttribute( 'data-index-h', i );
|
hslide.setAttribute( 'data-index-h', i );
|
||||||
hslide.style.WebkitTransform = htransform;
|
|
||||||
hslide.style.MozTransform = htransform;
|
// Apply CSS transform
|
||||||
hslide.style.msTransform = htransform;
|
transformElement( hslide, 'translateZ(-'+ depth +'px) translate(' + ( ( i - indexh ) * hoffset ) + '%, 0%)' );
|
||||||
hslide.style.OTransform = htransform;
|
|
||||||
hslide.style.transform = htransform;
|
|
||||||
|
|
||||||
if( hslide.classList.contains( 'stack' ) ) {
|
if( hslide.classList.contains( 'stack' ) ) {
|
||||||
|
|
||||||
@@ -1079,16 +1083,13 @@ var Reveal = (function(){
|
|||||||
for( var j = 0, len2 = verticalSlides.length; j < len2; j++ ) {
|
for( var j = 0, len2 = verticalSlides.length; j < len2; j++ ) {
|
||||||
var verticalIndex = i === indexh ? indexv : getPreviousVerticalIndex( hslide );
|
var verticalIndex = i === indexh ? indexv : getPreviousVerticalIndex( hslide );
|
||||||
|
|
||||||
var vslide = verticalSlides[j],
|
var vslide = verticalSlides[j];
|
||||||
vtransform = 'translate(0%, ' + ( ( j - verticalIndex ) * 105 ) + '%)';
|
|
||||||
|
|
||||||
vslide.setAttribute( 'data-index-h', i );
|
vslide.setAttribute( 'data-index-h', i );
|
||||||
vslide.setAttribute( 'data-index-v', j );
|
vslide.setAttribute( 'data-index-v', j );
|
||||||
vslide.style.WebkitTransform = vtransform;
|
|
||||||
vslide.style.MozTransform = vtransform;
|
// Apply CSS transform
|
||||||
vslide.style.msTransform = vtransform;
|
transformElement( vslide, 'translate(0%, ' + ( ( j - verticalIndex ) * 105 ) + '%)' );
|
||||||
vslide.style.OTransform = vtransform;
|
|
||||||
vslide.style.transform = vtransform;
|
|
||||||
|
|
||||||
// Navigate to this slide on click
|
// Navigate to this slide on click
|
||||||
vslide.addEventListener( 'click', onOverviewSlideClicked, true );
|
vslide.addEventListener( 'click', onOverviewSlideClicked, true );
|
||||||
@@ -1154,11 +1155,7 @@ var Reveal = (function(){
|
|||||||
element.style.display = '';
|
element.style.display = '';
|
||||||
|
|
||||||
// Resets all transforms to use the external styles
|
// Resets all transforms to use the external styles
|
||||||
element.style.WebkitTransform = '';
|
transformElement( element, '' );
|
||||||
element.style.MozTransform = '';
|
|
||||||
element.style.msTransform = '';
|
|
||||||
element.style.OTransform = '';
|
|
||||||
element.style.transform = '';
|
|
||||||
|
|
||||||
element.removeEventListener( 'click', onOverviewSlideClicked, true );
|
element.removeEventListener( 'click', onOverviewSlideClicked, true );
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
/*!
|
/*!
|
||||||
* reveal.js 2.5.0 (2013-08-13, 08:39)
|
* reveal.js 2.5.0 (2013-08-13, 09:26)
|
||||||
* http://lab.hakim.se/reveal-js
|
* http://lab.hakim.se/reveal-js
|
||||||
* MIT licensed
|
* MIT licensed
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Hakim El Hattab, http://hakim.se
|
* Copyright (C) 2013 Hakim El Hattab, http://hakim.se
|
||||||
*/
|
*/
|
||||||
var Reveal=function(){"use strict";function e(e){return t(),Nt||Dt?(window.addEventListener("load",A,!1),u(zt,e),a(),i(),void 0):(document.body.setAttribute("class","no-transforms"),void 0)}function t(){Dt="WebkitPerspective"in document.body.style||"MozPerspective"in document.body.style||"msPerspective"in document.body.style||"OPerspective"in document.body.style||"perspective"in document.body.style,Nt="WebkitTransform"in document.body.style||"MozTransform"in document.body.style||"msTransform"in document.body.style||"OTransform"in document.body.style||"transform"in document.body.style,Ct=navigator.userAgent.match(/(iphone|ipod|android)/gi)}function n(){jt.theme=document.querySelector("#theme"),jt.wrapper=document.querySelector(".reveal"),jt.slides=document.querySelector(".reveal .slides"),jt.slides.classList.add("no-transition"),jt.background=r(jt.wrapper,"div","backgrounds",null),jt.progress=r(jt.wrapper,"div","progress","<span></span>"),jt.progressbar=jt.progress.querySelector("span"),r(jt.wrapper,"aside","controls",'<div class="navigate-left"></div><div class="navigate-right"></div><div class="navigate-up"></div><div class="navigate-down"></div>'),r(jt.wrapper,"div","state-background",null),r(jt.wrapper,"div","pause-overlay",null),zt.controls&&(jt.controls=document.querySelector(".reveal .controls"),jt.controlsLeft=f(document.querySelectorAll(".navigate-left")),jt.controlsRight=f(document.querySelectorAll(".navigate-right")),jt.controlsUp=f(document.querySelectorAll(".navigate-up")),jt.controlsDown=f(document.querySelectorAll(".navigate-down")),jt.controlsPrev=f(document.querySelectorAll(".navigate-prev")),jt.controlsNext=f(document.querySelectorAll(".navigate-next")))}function r(e,t,n,r){var o=e.querySelector("."+n);return o||(o=document.createElement(t),o.classList.add(n),null!==r&&(o.innerHTML=r),e.appendChild(o)),o}function o(){function e(e,t){var n={background:e.getAttribute("data-background"),backgroundSize:e.getAttribute("data-background-size"),backgroundImage:e.getAttribute("data-background-image"),backgroundColor:e.getAttribute("data-background-color"),backgroundRepeat:e.getAttribute("data-background-repeat"),backgroundPosition:e.getAttribute("data-background-position"),backgroundTransition:e.getAttribute("data-background-transition")},r=document.createElement("div");return r.className="slide-background",n.background&&(/^(http|file|\/\/)/gi.test(n.background)||/\.(png|jpg|jpeg|gif|bmp)$/gi.test(n.background)?r.style.backgroundImage="url("+n.background+")":r.style.background=n.background),n.backgroundSize&&(r.style.backgroundSize=n.backgroundSize),n.backgroundImage&&(r.style.backgroundImage='url("'+n.backgroundImage+'")'),n.backgroundColor&&(r.style.backgroundColor=n.backgroundColor),n.backgroundRepeat&&(r.style.backgroundRepeat=n.backgroundRepeat),n.backgroundPosition&&(r.style.backgroundPosition=n.backgroundPosition),n.backgroundTransition&&r.setAttribute("data-background-transition",n.backgroundTransition),t.appendChild(r),r}m()&&document.body.classList.add("print-pdf"),jt.background.innerHTML="",jt.background.classList.add("no-transition"),f(document.querySelectorAll(It)).forEach(function(t){var n;n=m()?e(t,t):e(t,jt.background),f(t.querySelectorAll("section")).forEach(function(t){m()?e(t,t):e(t,n)})})}function a(){/iphone|ipod|android/gi.test(navigator.userAgent)&&!/crios/gi.test(navigator.userAgent)&&(window.addEventListener("load",g,!1),window.addEventListener("orientationchange",g,!1))}function i(){function e(){n.length&&head.js.apply(null,n),s()}for(var t=[],n=[],r=0,o=zt.dependencies.length;o>r;r++){var a=zt.dependencies[r];(!a.condition||a.condition())&&(a.async?n.push(a.src):t.push(a.src),"function"==typeof a.callback&&head.ready(a.src.match(/([\w\d_\-]*)\.?js$|[^\\\/]*$/i)[0],a.callback))}t.length?(head.ready(e),head.js.apply(null,t)):e()}function s(){n(),c(),Z(),setTimeout(function(){jt.slides.classList.remove("no-transition"),Xt=!0,h("ready",{indexh:xt,indexv:Tt,currentSlide:Pt})},1)}function c(e){if(jt.wrapper.classList.remove(zt.transition),"object"==typeof e&&u(zt,e),Dt===!1&&(zt.transition="linear"),jt.wrapper.classList.add(zt.transition),jt.wrapper.setAttribute("data-transition-speed",zt.transitionSpeed),jt.wrapper.setAttribute("data-background-transition",zt.backgroundTransition),jt.controls&&(jt.controls.style.display=zt.controls&&jt.controls?"block":"none"),jt.progress&&(jt.progress.style.display=zt.progress&&jt.progress?"block":"none"),zt.rtl?jt.wrapper.classList.add("rtl"):jt.wrapper.classList.remove("rtl"),zt.center?jt.wrapper.classList.add("center"):jt.wrapper.classList.remove("center"),zt.mouseWheel?(document.addEventListener("DOMMouseScroll",mt,!1),document.addEventListener("mousewheel",mt,!1)):(document.removeEventListener("DOMMouseScroll",mt,!1),document.removeEventListener("mousewheel",mt,!1)),zt.rollingLinks?y():b(),zt.previewLinks?w():(L(),w("[data-preview-link]")),zt.theme&&jt.theme){var t=jt.theme.getAttribute("href"),n=/[^\/]*?(?=\.css)/,r=t.match(n)[0];zt.theLine truncated
|
var Reveal=function(){"use strict";function e(e){return t(),Ct||Nt?(window.addEventListener("load",q,!1),d(Ot,e),a(),i(),void 0):(document.body.setAttribute("class","no-transforms"),void 0)}function t(){Nt="WebkitPerspective"in document.body.style||"MozPerspective"in document.body.style||"msPerspective"in document.body.style||"OPerspective"in document.body.style||"perspective"in document.body.style,Ct="WebkitTransform"in document.body.style||"MozTransform"in document.body.style||"msTransform"in document.body.style||"OTransform"in document.body.style||"transform"in document.body.style,Rt=navigator.userAgent.match(/(iphone|ipod|android)/gi)}function n(){Ft.theme=document.querySelector("#theme"),Ft.wrapper=document.querySelector(".reveal"),Ft.slides=document.querySelector(".reveal .slides"),Ft.slides.classList.add("no-transition"),Ft.background=r(Ft.wrapper,"div","backgrounds",null),Ft.progress=r(Ft.wrapper,"div","progress","<span></span>"),Ft.progressbar=Ft.progress.querySelector("span"),r(Ft.wrapper,"aside","controls",'<div class="navigate-left"></div><div class="navigate-right"></div><div class="navigate-up"></div><div class="navigate-down"></div>'),r(Ft.wrapper,"div","state-background",null),r(Ft.wrapper,"div","pause-overlay",null),Ot.controls&&(Ft.controls=document.querySelector(".reveal .controls"),Ft.controlsLeft=f(document.querySelectorAll(".navigate-left")),Ft.controlsRight=f(document.querySelectorAll(".navigate-right")),Ft.controlsUp=f(document.querySelectorAll(".navigate-up")),Ft.controlsDown=f(document.querySelectorAll(".navigate-down")),Ft.controlsPrev=f(document.querySelectorAll(".navigate-prev")),Ft.controlsNext=f(document.querySelectorAll(".navigate-next")))}function r(e,t,n,r){var o=e.querySelector("."+n);return o||(o=document.createElement(t),o.classList.add(n),null!==r&&(o.innerHTML=r),e.appendChild(o)),o}function o(){function e(e,t){var n={background:e.getAttribute("data-background"),backgroundSize:e.getAttribute("data-background-size"),backgroundImage:e.getAttribute("data-background-image"),backgroundColor:e.getAttribute("data-background-color"),backgroundRepeat:e.getAttribute("data-background-repeat"),backgroundPosition:e.getAttribute("data-background-position"),backgroundTransition:e.getAttribute("data-background-transition")},r=document.createElement("div");return r.className="slide-background",n.background&&(/^(http|file|\/\/)/gi.test(n.background)||/\.(png|jpg|jpeg|gif|bmp)$/gi.test(n.background)?r.style.backgroundImage="url("+n.background+")":r.style.background=n.background),n.backgroundSize&&(r.style.backgroundSize=n.backgroundSize),n.backgroundImage&&(r.style.backgroundImage='url("'+n.backgroundImage+'")'),n.backgroundColor&&(r.style.backgroundColor=n.backgroundColor),n.backgroundRepeat&&(r.style.backgroundRepeat=n.backgroundRepeat),n.backgroundPosition&&(r.style.backgroundPosition=n.backgroundPosition),n.backgroundTransition&&r.setAttribute("data-background-transition",n.backgroundTransition),t.appendChild(r),r}m()&&document.body.classList.add("print-pdf"),Ft.background.innerHTML="",Ft.background.classList.add("no-transition"),f(document.querySelectorAll(Yt)).forEach(function(t){var n;n=m()?e(t,t):e(t,Ft.background),f(t.querySelectorAll("section")).forEach(function(t){m()?e(t,t):e(t,n)})})}function a(){/iphone|ipod|android/gi.test(navigator.userAgent)&&!/crios/gi.test(navigator.userAgent)&&(window.addEventListener("load",h,!1),window.addEventListener("orientationchange",h,!1))}function i(){function e(){n.length&&head.js.apply(null,n),s()}for(var t=[],n=[],r=0,o=Ot.dependencies.length;o>r;r++){var a=Ot.dependencies[r];(!a.condition||a.condition())&&(a.async?n.push(a.src):t.push(a.src),"function"==typeof a.callback&&head.ready(a.src.match(/([\w\d_\-]*)\.?js$|[^\\\/]*$/i)[0],a.callback))}t.length?(head.ready(e),head.js.apply(null,t)):e()}function s(){n(),c(),Q(),setTimeout(function(){Ft.slides.classList.remove("no-transition"),zt=!0,b("ready",{indexh:Tt,indexv:Mt,currentSlide:Dt})},1)}function c(e){if(Ft.wrapper.classList.remove(Ot.transition),"object"==typeof e&&d(Ot,e),Nt===!1&&(Ot.transition="linear"),Ft.wrapper.classList.add(Ot.transition),Ft.wrapper.setAttribute("data-transition-speed",Ot.transitionSpeed),Ft.wrapper.setAttribute("data-background-transition",Ot.backgroundTransition),Ft.controls&&(Ft.controls.style.display=Ot.controls&&Ft.controls?"block":"none"),Ft.progress&&(Ft.progress.style.display=Ot.progress&&Ft.progress?"block":"none"),Ot.rtl?Ft.wrapper.classList.add("rtl"):Ft.wrapper.classList.remove("rtl"),Ot.center?Ft.wrapper.classList.add("center"):Ft.wrapper.classList.remove("center"),Ot.mouseWheel?(document.addEventListener("DOMMouseScroll",mt,!1),document.addEventListener("mousewheel",mt,!1)):(document.removeEventListener("DOMMouseScroll",mt,!1),document.removeEventListener("mousewheel",mt,!1)),Ot.rollingLinks?y():w(),Ot.previewLinks?L():(E(),L("[data-preview-link]")),Ot.theme&&Ft.theme){var t=Ft.theme.getAttribute("href"),n=/[^\/]*?(?=\.css)/,r=t.match(n)[0];Ot.theLine truncated
|
||||||
Reference in new issue
Block a user