1
0
mirror of https://github.com/webslides/WebSlides.git synced 2025-08-23 13:23:23 +02:00

Adding some transitioning to zoom

This commit is contained in:
Antonio Laguna
2017-06-28 16:56:53 +02:00
parent 377de1f0be
commit 811007da8d
5 changed files with 128 additions and 74 deletions

View File

@@ -133,9 +133,7 @@ export default class Zoom {
*/ */
zoomIn() { zoomIn() {
DOM.show(this.zws_.el); DOM.show(this.zws_.el);
const currentId = this.ws_.el const currentId = this.ws_.currentSlide_.el.id;
.querySelector(`.${CLASSES.SLIDE}.${CLASSES.CURRENT}`)
.getAttribute('id');
const zoomedCurrent = this.zws_.el const zoomedCurrent = this.zws_.el
.querySelector(`.${CLASSES.WRAP}.${CLASSES.CURRENT}`); .querySelector(`.${CLASSES.WRAP}.${CLASSES.CURRENT}`);
if (zoomedCurrent) { if (zoomedCurrent) {
@@ -145,22 +143,26 @@ export default class Zoom {
.querySelector(`#zoomed-${currentId}`) .querySelector(`#zoomed-${currentId}`)
.classList.add(CLASSES.CURRENT); .classList.add(CLASSES.CURRENT);
setTimeout(() => {
this.ws_.disable();
}, 400);
this.isZoomed_ = true; this.isZoomed_ = true;
document.body.style.overflow = 'auto'; document.body.style.overflow = 'auto';
setTimeout(() => {
this.ws_.disable();
this.zws_.el.classList.add('in');
}, 50);
} }
/** /**
* Zoom Out the slider, remove scale from the slides. * Zoom Out the slider, remove scale from the slides.
*/ */
zoomOut() { zoomOut() {
this.zws_.el.classList.remove('in');
setTimeout(() => { setTimeout(() => {
DOM.hide(this.zws_.el);
this.ws_.enable(); this.ws_.enable();
}, 400); DOM.hide(this.zws_.el);
this.isZoomed_ = false; this.isZoomed_ = false;
document.body.style.overflow = ''; document.body.style.overflow = '';
}, 400);
} }
} }

View File

@@ -95,6 +95,20 @@
transform: scale(.5) translate(-50%, -50%); transform: scale(.5) translate(-50%, -50%);
} }
} }
& .column {
opacity: 0;
transform: scale(1.2);
transition: opacity .4s, transform .4s;
transition-delay: .2s;
}
&.in {
.column {
opacity: 1;
transform: scale(1);
}
}
} }
.text-slide-number { .text-slide-number {
@@ -104,6 +118,8 @@
} }
#webslides { #webslides {
transition: filter .3s;
&.disabled, &.disabled,
&.zooming { &.zooming {
position: fixed; position: fixed;

View File

@@ -1,7 +1,7 @@
/*! /*!
* Name: WebSlides * Name: WebSlides
* Version: 1.3.1 * Version: 1.3.1
* Date: 2017-06-27 * Date: 2017-06-28
* Description: Making HTML presentations easy * Description: Making HTML presentations easy
* URL: https://github.com/webslides/webslides#readme * URL: https://github.com/webslides/webslides#readme
* Credits: @jlantunez, @LuisSacristan, @Belelros * Credits: @jlantunez, @LuisSacristan, @Belelros
@@ -46,8 +46,8 @@
14. Forms 14. Forms
15. Longform Elements 15. Longform Elements
16. Safari Bug (flex-wrap) 16. Safari Bug (flex-wrap)
17. Print 17. Slidex index (aka zoom)
18. Slidex index (aka zoom) 18. Print
19. Colors 19. Colors
----------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------------- */
/* /*
@@ -2865,44 +2865,6 @@ Solution: stackoverflow.com/questions/34250282/flexbox-safari-bug-flex-wrap
.cta:after { .cta:after {
width: 0; } width: 0; }
/*=========================================
17. PRINT
=========================================== */
@media print {
@page {
margin: .5cm;
size: A4 landscape; }
* {
background: transparent !important;
color: #000 !important;
-webkit-filter: none !important;
filter: none !important;
text-shadow: none !important; }
html,
body,
#webslides {
height: auto !important;
overflow: auto !important;
width: auto !important; }
#webslides {
overflow-x: auto !important;
overflow-y: auto !important; }
section,
.slide {
display: -webkit-box !important;
display: -ms-flexbox !important;
display: flex !important;
height: auto !important; }
section * {
-webkit-animation: none;
animation: none; }
table,
figure {
page-break-inside: avoid; }
#counter,
#navigation {
display: none; } }
/*============================================== /*==============================================
18. Slides Index: Thumbnails navigation gallery 18. Slides Index: Thumbnails navigation gallery
================================================ */ ================================================ */
@@ -2996,21 +2958,77 @@ Solution: stackoverflow.com/questions/34250282/flexbox-safari-bug-flex-wrap
#webslides-zoomed .column > .wrap-zoom > .slide { #webslides-zoomed .column > .wrap-zoom > .slide {
-webkit-transform: scale(0.5) translate(-50%, -50%); -webkit-transform: scale(0.5) translate(-50%, -50%);
transform: scale(0.5) translate(-50%, -50%); } } transform: scale(0.5) translate(-50%, -50%); } }
#webslides-zoomed .column {
opacity: 0;
-webkit-transform: scale(1.2);
transform: scale(1.2);
-webkit-transition: opacity .4s, -webkit-transform .4s;
transition: opacity .4s, -webkit-transform .4s;
transition: opacity .4s, transform .4s;
transition: opacity .4s, transform .4s, -webkit-transform .4s;
-webkit-transition-delay: .2s;
transition-delay: .2s; }
#webslides-zoomed.in .column {
opacity: 1;
-webkit-transform: scale(1);
transform: scale(1); }
.text-slide-number { .text-slide-number {
display: inline-block; display: inline-block;
margin: .8rem auto; margin: .8rem auto;
text-align: center; } text-align: center; }
#webslides.disabled, #webslides.zooming { #webslides {
-webkit-transition: -webkit-filter .3s;
transition: -webkit-filter .3s;
transition: filter .3s;
transition: filter .3s, -webkit-filter .3s; }
#webslides.disabled, #webslides.zooming {
position: fixed; position: fixed;
width: 100%; width: 100%;
z-index: 0; } z-index: 0; }
#webslides.disabled {
#webslides.disabled {
-webkit-filter: blur(10px); -webkit-filter: blur(10px);
filter: blur(10px); } filter: blur(10px); }
/*=========================================
17. PRINT
=========================================== */
@media print {
@page {
margin: .5cm;
size: A4 landscape; }
* {
background: transparent !important;
color: #000 !important;
-webkit-filter: none !important;
filter: none !important;
text-shadow: none !important; }
html,
body,
#webslides {
height: auto !important;
overflow: auto !important;
width: auto !important; }
#webslides {
overflow-x: auto !important;
overflow-y: auto !important; }
section,
.slide {
display: -webkit-box !important;
display: -ms-flexbox !important;
display: flex !important;
height: auto !important; }
section * {
-webkit-animation: none;
animation: none; }
table,
figure {
page-break-inside: avoid; }
#counter,
#navigation {
display: none; } }
/*========================================= /*=========================================
19. Colors 19. Colors
=========================================== */ =========================================== */
@@ -3273,7 +3291,8 @@ nav[role='navigation'] li.active a {
color: #fff; } color: #fff; }
nav[role='navigation'] li a { nav[role='navigation'] li a {
background-color: rgba(50, 50, 50, 0.9); } background-color: rgba(50, 50, 50, 0.9);
color: #fff; }
nav[role='navigation'] li a:hover { nav[role='navigation'] li a:hover {
background-color: rgba(50, 50, 50, 0.7); } background-color: rgba(50, 50, 50, 0.7); }

View File

@@ -1,7 +1,7 @@
/*! /*!
* Name: WebSlides * Name: WebSlides
* Version: 1.3.1 * Version: 1.3.1
* Date: 2017-06-27 * Date: 2017-06-28
* Description: Making HTML presentations easy * Description: Making HTML presentations easy
* URL: https://github.com/webslides/webslides#readme * URL: https://github.com/webslides/webslides#readme
* Credits: @jlantunez, @LuisSacristan, @Belelros * Credits: @jlantunez, @LuisSacristan, @Belelros
@@ -1152,6 +1152,10 @@ var WebSlides = function () {
key: 'disable', key: 'disable',
value: function disable() { value: function disable() {
this.el.classList.add(CLASSES.DISABLED); this.el.classList.add(CLASSES.DISABLED);
if (this.plugins.autoslide && this.plugins.autoslide.time !== false) {
this.plugins.autoslide.stop();
}
} }
/** /**
@@ -1162,6 +1166,10 @@ var WebSlides = function () {
key: 'enable', key: 'enable',
value: function enable() { value: function enable() {
this.el.classList.remove(CLASSES.DISABLED); this.el.classList.remove(CLASSES.DISABLED);
if (this.plugins.autoslide && this.plugins.autoslide.time !== false) {
this.plugins.autoslide.play();
}
} }
/** /**
@@ -2769,9 +2777,13 @@ var Zoom = function () {
_createClass(Zoom, [{ _createClass(Zoom, [{
key: 'onKeyDown', key: 'onKeyDown',
value: function onKeyDown(event) { value: function onKeyDown(event) {
if (!this.isZoomed_ && __WEBPACK_IMPORTED_MODULE_1__utils_keys__["a" /* default */].MINUS.includes(event.which)) { if (!this.isZoomed_ && __WEBPACK_IMPORTED_MODULE_1__utils_keys__["a" /* default */].MINUS.some(function (key) {
return key === event.which;
})) {
this.zoomIn(); this.zoomIn();
} else if (this.isZoomed_ && (__WEBPACK_IMPORTED_MODULE_1__utils_keys__["a" /* default */].PLUS.includes(event.which) || event.which === __WEBPACK_IMPORTED_MODULE_1__utils_keys__["a" /* default */].ESCAPE)) { } else if (this.isZoomed_ && (__WEBPACK_IMPORTED_MODULE_1__utils_keys__["a" /* default */].PLUS.some(function (key) {
return key === event.which;
}) || event.which === __WEBPACK_IMPORTED_MODULE_1__utils_keys__["a" /* default */].ESCAPE)) {
this.zoomOut(); this.zoomOut();
} }
} }
@@ -2872,17 +2884,20 @@ var Zoom = function () {
var _this3 = this; var _this3 = this;
__WEBPACK_IMPORTED_MODULE_0__utils_dom__["a" /* default */].show(this.zws_.el); __WEBPACK_IMPORTED_MODULE_0__utils_dom__["a" /* default */].show(this.zws_.el);
var currentId = this.ws_.el.querySelector('.' + CLASSES.SLIDE + '.' + CLASSES.CURRENT).getAttribute('id'); var currentId = this.ws_.currentSlide_.el.id;
var zoomedCurrent = this.zws_.el.querySelector('.' + CLASSES.WRAP + '.' + CLASSES.CURRENT); var zoomedCurrent = this.zws_.el.querySelector('.' + CLASSES.WRAP + '.' + CLASSES.CURRENT);
if (zoomedCurrent) { if (zoomedCurrent) {
zoomedCurrent.classList.remove(CLASSES.CURRENT); zoomedCurrent.classList.remove(CLASSES.CURRENT);
} }
this.zws_.el.querySelector('#zoomed-' + currentId).classList.add(CLASSES.CURRENT); this.zws_.el.querySelector('#zoomed-' + currentId).classList.add(CLASSES.CURRENT);
setTimeout(function () {
_this3.ws_.disable();
}, 400);
this.isZoomed_ = true; this.isZoomed_ = true;
document.body.style.overflow = 'auto'; document.body.style.overflow = 'auto';
setTimeout(function () {
_this3.ws_.disable();
_this3.zws_.el.classList.add('in');
}, 50);
} }
/** /**
@@ -2894,12 +2909,14 @@ var Zoom = function () {
value: function zoomOut() { value: function zoomOut() {
var _this4 = this; var _this4 = this;
this.zws_.el.classList.remove('in');
setTimeout(function () { setTimeout(function () {
__WEBPACK_IMPORTED_MODULE_0__utils_dom__["a" /* default */].hide(_this4.zws_.el);
_this4.ws_.enable(); _this4.ws_.enable();
}, 400); __WEBPACK_IMPORTED_MODULE_0__utils_dom__["a" /* default */].hide(_this4.zws_.el);
this.isZoomed_ = false; _this4.isZoomed_ = false;
document.body.style.overflow = ''; document.body.style.overflow = '';
}, 400);
} }
}]); }]);

File diff suppressed because one or more lines are too long