Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Commit

Permalink
Updated to v3.5.2
Browse files Browse the repository at this point in the history
Fixed #2090 - Html5 video in looping gallery;
Fixed issue with long pdf files (by disabling iframe preloading)
  • Loading branch information
fancyapps committed Oct 5, 2018
1 parent 8f199f5 commit 920b3e4
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 42 deletions.
3 changes: 3 additions & 0 deletions dist/jquery.fancybox.css
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ body.compensate-for-scrollbar {

.fancybox-slide--video .fancybox-content,
.fancybox-slide--map .fancybox-content,
.fancybox-slide--pdf .fancybox-content,
.fancybox-slide--iframe .fancybox-content {
height: 100%;
overflow: visible;
Expand Down Expand Up @@ -572,6 +573,8 @@ body.compensate-for-scrollbar {
padding-right: 6px; }
.fancybox-slide--image {
padding: 6px 0; }
.fancybox-close-small {
right: -6px; }
.fancybox-slide--image .fancybox-close-small {
background: #4e4e4e;
color: #f2f4f6;
Expand Down
54 changes: 35 additions & 19 deletions dist/jquery.fancybox.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ==================================================
// fancyBox v3.5.1
// fancyBox v3.5.2
//
// Licensed GPLv3 for open source use
// or fancyBox Commercial License for commercial use
Expand Down Expand Up @@ -642,7 +642,7 @@
// ============================================================

translate: function(obj, str) {
var arr = obj.opts.i18n[obj.opts.lang];
var arr = obj.opts.i18n[obj.opts.lang] || obj.opts.i18n.en;

return str.replace(/\{\{(\w+)\}\}/g, function(match, n) {
var value = arr[n];
Expand Down Expand Up @@ -739,6 +739,7 @@
type = "image";
} else if (src.match(/\.(pdf)((\?|#).*)?$/i)) {
type = "iframe";
obj = $.extend(true, obj, {contentType: "pdf", opts: {iframe: {preload: false}}});
} else if (src.charAt(0) === "#") {
type = "inline";
}
Expand Down Expand Up @@ -1780,15 +1781,13 @@
ghost;

// Check if need to show loading icon
requestAFrame(function() {
requestAFrame(function() {
var $img = slide.$image;
setTimeout(function() {
var $img = slide.$image;

if (!self.isClosing && slide.isLoading && (!$img || !$img.length || !$img[0].complete) && !slide.hasError) {
self.showLoading(slide);
}
});
});
if (!self.isClosing && slide.isLoading && (!$img || !$img.length || !$img[0].complete) && !slide.hasError) {
self.showLoading(slide);
}
}, 50);

//Check if image has srcset
self.checkSrcset(slide);
Expand Down Expand Up @@ -2111,8 +2110,8 @@
// The placeholder is created so we will know where to put it back.
if (isQuery(content) && content.parent().length) {
// Make sure content is not already moved to fancyBox
if (content.hasClass("fancybox-content")) {
content.parent(".fancybox-slide--html").trigger("onReset");
if (content.hasClass("fancybox-content") || content.parent().hasClass("fancybox-content")) {
content.parents(".fancybox-slide").trigger("onReset");
}

// Create temporary element marking original place of the content
Expand Down Expand Up @@ -2586,7 +2585,13 @@
.find("video,audio")
.filter(":visible:first")
.trigger("play")
.on("ended", $.proxy(self.next, self));
.one("ended", function() {
if (this.webkitExitFullscreen) {
this.webkitExitFullscreen();
}

self.next();
});
}

// Try to focus on the first focusable element
Expand All @@ -2610,8 +2615,15 @@

preload: function(type) {
var self = this,
next = self.slides[self.currPos + 1],
prev = self.slides[self.currPos - 1];
prev,
next;

if (self.group.length < 2) {
return;
}

next = self.slides[self.currPos + 1];
prev = self.slides[self.currPos - 1];

if (prev && prev.type === type) {
self.loadSlide(prev);
Expand Down Expand Up @@ -3029,7 +3041,7 @@
});

$.fancybox = {
version: "3.5.1",
version: "3.5.2",
defaults: defaults,

// Get current instance and execute a command.
Expand Down Expand Up @@ -4687,7 +4699,11 @@
}

self.timer = setTimeout(function() {
instance.jumpTo((instance.currIndex + 1) % instance.group.length);
if (!instance.current.opts.loop && instance.current.index == instance.group.length - 1) {
instance.jumpTo(0);
} else {
instance.next();
}
}, current.opts.slideShow.speed);
}
} else {
Expand Down Expand Up @@ -4715,7 +4731,7 @@

if (current) {
self.$button
.attr("title", current.opts.i18n[current.opts.lang].PLAY_STOP)
.attr("title", (current.opts.i18n[current.opts.lang] || current.opts.i18n.en).PLAY_STOP)
.removeClass("fancybox-button--play")
.addClass("fancybox-button--pause");

Expand All @@ -4736,7 +4752,7 @@
self.clear();

self.$button
.attr("title", current.opts.i18n[current.opts.lang].PLAY_START)
.attr("title", (current.opts.i18n[current.opts.lang] || current.opts.i18n.en).PLAY_START)
.removeClass("fancybox-button--pause")
.addClass("fancybox-button--play");

Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.fancybox.min.css

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/jquery.fancybox.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@fancyapps/fancybox",
"description": "Touch enabled, responsive and fully customizable jQuery lightbox script",
"version": "3.5.1",
"version": "3.5.2",
"homepage": "https://fancyapps.com/fancybox/3/",
"main": "dist/jquery.fancybox.js",
"style": "dist/jquery.fancybox.css",
Expand Down
5 changes: 5 additions & 0 deletions src/css/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ body.compensate-for-scrollbar {

.fancybox-slide--video .fancybox-content,
.fancybox-slide--map .fancybox-content,
.fancybox-slide--pdf .fancybox-content,
.fancybox-slide--iframe .fancybox-content {
height: 100%;
overflow: visible;
Expand Down Expand Up @@ -618,6 +619,10 @@ body.compensate-for-scrollbar {
padding: 6px 0;
}

.fancybox-close-small {
right: -6px;
}

.fancybox-slide--image .fancybox-close-small {
background: #4e4e4e;
color: #f2f4f6;
Expand Down
40 changes: 26 additions & 14 deletions src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@
// ============================================================

translate: function(obj, str) {
var arr = obj.opts.i18n[obj.opts.lang];
var arr = obj.opts.i18n[obj.opts.lang] || obj.opts.i18n.en;

return str.replace(/\{\{(\w+)\}\}/g, function(match, n) {
var value = arr[n];
Expand Down Expand Up @@ -729,6 +729,7 @@
type = "image";
} else if (src.match(/\.(pdf)((\?|#).*)?$/i)) {
type = "iframe";
obj = $.extend(true, obj, {contentType: "pdf", opts: {iframe: {preload: false}}});
} else if (src.charAt(0) === "#") {
type = "inline";
}
Expand Down Expand Up @@ -1770,15 +1771,13 @@
ghost;

// Check if need to show loading icon
requestAFrame(function() {
requestAFrame(function() {
var $img = slide.$image;
setTimeout(function() {
var $img = slide.$image;

if (!self.isClosing && slide.isLoading && (!$img || !$img.length || !$img[0].complete) && !slide.hasError) {
self.showLoading(slide);
}
});
});
if (!self.isClosing && slide.isLoading && (!$img || !$img.length || !$img[0].complete) && !slide.hasError) {
self.showLoading(slide);
}
}, 50);

//Check if image has srcset
self.checkSrcset(slide);
Expand Down Expand Up @@ -2101,8 +2100,8 @@
// The placeholder is created so we will know where to put it back.
if (isQuery(content) && content.parent().length) {
// Make sure content is not already moved to fancyBox
if (content.hasClass("fancybox-content")) {
content.parent(".fancybox-slide--html").trigger("onReset");
if (content.hasClass("fancybox-content") || content.parent().hasClass("fancybox-content")) {
content.parents(".fancybox-slide").trigger("onReset");
}

// Create temporary element marking original place of the content
Expand Down Expand Up @@ -2576,7 +2575,13 @@
.find("video,audio")
.filter(":visible:first")
.trigger("play")
.on("ended", $.proxy(self.next, self));
.one("ended", function() {
if (this.webkitExitFullscreen) {
this.webkitExitFullscreen();
}

self.next();
});
}

// Try to focus on the first focusable element
Expand All @@ -2600,8 +2605,15 @@

preload: function(type) {
var self = this,
next = self.slides[self.currPos + 1],
prev = self.slides[self.currPos - 1];
prev,
next;

if (self.group.length < 2) {
return;
}

next = self.slides[self.currPos + 1];
prev = self.slides[self.currPos - 1];

if (prev && prev.type === type) {
self.loadSlide(prev);
Expand Down
10 changes: 7 additions & 3 deletions src/js/slideshow.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@
}

self.timer = setTimeout(function() {
instance.jumpTo((instance.currIndex + 1) % instance.group.length);
if (!instance.current.opts.loop && instance.current.index == instance.group.length - 1) {
instance.jumpTo(0);
} else {
instance.next();
}
}, current.opts.slideShow.speed);
}
} else {
Expand Down Expand Up @@ -92,7 +96,7 @@

if (current) {
self.$button
.attr("title", current.opts.i18n[current.opts.lang].PLAY_STOP)
.attr("title", (current.opts.i18n[current.opts.lang] || current.opts.i18n.en).PLAY_STOP)
.removeClass("fancybox-button--play")
.addClass("fancybox-button--pause");

Expand All @@ -113,7 +117,7 @@
self.clear();

self.$button
.attr("title", current.opts.i18n[current.opts.lang].PLAY_START)
.attr("title", (current.opts.i18n[current.opts.lang] || current.opts.i18n.en).PLAY_START)
.removeClass("fancybox-button--pause")
.addClass("fancybox-button--play");

Expand Down

0 comments on commit 920b3e4

Please sign in to comment.