Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting open and close effect individually #341

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,16 @@ You can specify some options to each individual slide, the available options are
- description
- descPosition
- type
- effect
- openEffect
- closeEffect
- width
- height
- zoomable
- draggable

```html
<!-- One line config -->
<a href="large.jpg" data-glightbox="title: Your title; description: description here; descPosition: left; type: image; effect: fade; width: 900px; height: auto; zoomable: true; draggable: true;"></a>
<a href="large.jpg" data-glightbox="title: Your title; description: description here; descPosition: left; type: image; openEffect: fade; closeEffect: fade; width: 900px; height: auto; zoomable: true; draggable: true;"></a>

<!-- Multiple data attributes / You can use the options as separated data attributes -->
<a
Expand All @@ -145,7 +146,8 @@ You can specify some options to each individual slide, the available options are
data-description="description here"
data-desc-position="right"
data-type="image"
data-effect="fade"
data-open-effect="fade"
data-close-effect="fade"
data-width="900px"
data-height="auto"
data-zoomable="true"
Expand Down
33 changes: 16 additions & 17 deletions dist/js/glightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,11 @@
function _typeof(obj) {
"@babel/helpers - typeof";

if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}

return _typeof(obj);
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
}, _typeof(obj);
}

function _classCallCheck(instance, Constructor) {
Expand All @@ -39,6 +33,9 @@
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}

Expand Down Expand Up @@ -1999,7 +1996,9 @@
var _this = this;

var data = extend({
descPosition: settings.descPosition
descPosition: settings.descPosition,
openEffect: settings.openEffect,
closeEffect: settings.closeEffect
}, this.defaults);

if (isObject(element) && !isNode(element)) {
Expand Down Expand Up @@ -2388,7 +2387,7 @@
return Slide;
}();

var _version = '3.1.0';
var _version = '3.2.0';

var isMobile$1 = isMobile();

Expand Down Expand Up @@ -2561,7 +2560,7 @@

this.build();

animateElement(this.overlay, this.settings.openEffect === 'none' ? 'none' : this.settings.cssEfects.fade["in"]);
animateElement(this.overlay, this.elements[index].openEffect === 'none' ? 'none' : this.settings.cssEfects.fade["in"]);

var body = document.body;
var scrollBar = window.innerWidth - document.documentElement.clientWidth;
Expand Down Expand Up @@ -2882,7 +2881,7 @@
removeClass(slide, this.effectsClasses);

if (first) {
animateElement(slide, this.settings.cssEfects[this.settings.openEffect]["in"], function () {
animateElement(slide, this.settings.cssEfects[this.elements[this.index].openEffect]["in"], function () {
if (_this4.settings.autoplayVideos) {
_this4.slidePlayerPlay(slide);
}
Expand Down Expand Up @@ -3528,9 +3527,9 @@

addClass(this.modal, 'glightbox-closing');

animateElement(this.overlay, this.settings.openEffect == 'none' ? 'none' : this.settings.cssEfects.fade.out);
animateElement(this.overlay, this.elements[this.index].openEffect == 'none' ? 'none' : this.settings.cssEfects.fade.out);

animateElement(this.activeSlide, this.settings.cssEfects[this.settings.closeEffect].out, function () {
animateElement(this.activeSlide, this.settings.cssEfects[this.elements[this.index].closeEffect].out, function () {
_this8.activeSlide = null;
_this8.prevActiveSlideIndex = null;
_this8.prevActiveSlide = null;
Expand Down
2 changes: 1 addition & 1 deletion dist/js/glightbox.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/js/core/slide-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ export default class SlideConfigParser {
}

parseConfig(element, settings) {
let data = extend({ descPosition: settings.descPosition }, this.defaults);
let data = extend({
descPosition: settings.descPosition,
openEffect: settings.openEffect,
closeEffect: settings.closeEffect
}, this.defaults);

if (isObject(element) && !isNode(element)) {
if (!has(element, 'type')) {
Expand Down
8 changes: 4 additions & 4 deletions src/js/glightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class GlightboxInit {

this.build();

_.animateElement(this.overlay, this.settings.openEffect === 'none' ? 'none' : this.settings.cssEfects.fade.in);
_.animateElement(this.overlay, this.elements[index].openEffect === 'none' ? 'none' : this.settings.cssEfects.fade.in);

const body = document.body;

Expand Down Expand Up @@ -521,7 +521,7 @@ class GlightboxInit {
_.removeClass(slide, this.effectsClasses);

if (first) {
_.animateElement(slide, this.settings.cssEfects[this.settings.openEffect].in, () => {
_.animateElement(slide, this.settings.cssEfects[this.elements[this.index].openEffect].in, () => {
if (this.settings.autoplayVideos) {
this.slidePlayerPlay(slide);
}
Expand Down Expand Up @@ -1220,8 +1220,8 @@ class GlightboxInit {
}

_.addClass(this.modal, 'glightbox-closing');
_.animateElement(this.overlay, this.settings.openEffect == 'none' ? 'none' : this.settings.cssEfects.fade.out);
_.animateElement(this.activeSlide, this.settings.cssEfects[this.settings.closeEffect].out, () => {
_.animateElement(this.overlay, this.elements[this.index].openEffect == 'none' ? 'none' : this.settings.cssEfects.fade.out);
_.animateElement(this.activeSlide, this.settings.cssEfects[this.elements[this.index].closeEffect].out, () => {
this.activeSlide = null;
this.prevActiveSlideIndex = null;
this.prevActiveSlide = null;
Expand Down