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

Commit 920b3e4

Browse files
committed
Updated to v3.5.2
Fixed #2090 - Html5 video in looping gallery; Fixed issue with long pdf files (by disabling iframe preloading)
1 parent 8f199f5 commit 920b3e4

File tree

8 files changed

+82
-42
lines changed

8 files changed

+82
-42
lines changed

dist/jquery.fancybox.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ body.compensate-for-scrollbar {
229229

230230
.fancybox-slide--video .fancybox-content,
231231
.fancybox-slide--map .fancybox-content,
232+
.fancybox-slide--pdf .fancybox-content,
232233
.fancybox-slide--iframe .fancybox-content {
233234
height: 100%;
234235
overflow: visible;
@@ -572,6 +573,8 @@ body.compensate-for-scrollbar {
572573
padding-right: 6px; }
573574
.fancybox-slide--image {
574575
padding: 6px 0; }
576+
.fancybox-close-small {
577+
right: -6px; }
575578
.fancybox-slide--image .fancybox-close-small {
576579
background: #4e4e4e;
577580
color: #f2f4f6;

dist/jquery.fancybox.js

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ==================================================
2-
// fancyBox v3.5.1
2+
// fancyBox v3.5.2
33
//
44
// Licensed GPLv3 for open source use
55
// or fancyBox Commercial License for commercial use
@@ -642,7 +642,7 @@
642642
// ============================================================
643643

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

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

17821783
// Check if need to show loading icon
1783-
requestAFrame(function() {
1784-
requestAFrame(function() {
1785-
var $img = slide.$image;
1784+
setTimeout(function() {
1785+
var $img = slide.$image;
17861786

1787-
if (!self.isClosing && slide.isLoading && (!$img || !$img.length || !$img[0].complete) && !slide.hasError) {
1788-
self.showLoading(slide);
1789-
}
1790-
});
1791-
});
1787+
if (!self.isClosing && slide.isLoading && (!$img || !$img.length || !$img[0].complete) && !slide.hasError) {
1788+
self.showLoading(slide);
1789+
}
1790+
}, 50);
17921791

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

21182117
// Create temporary element marking original place of the content
@@ -2586,7 +2585,13 @@
25862585
.find("video,audio")
25872586
.filter(":visible:first")
25882587
.trigger("play")
2589-
.on("ended", $.proxy(self.next, self));
2588+
.one("ended", function() {
2589+
if (this.webkitExitFullscreen) {
2590+
this.webkitExitFullscreen();
2591+
}
2592+
2593+
self.next();
2594+
});
25902595
}
25912596

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

26112616
preload: function(type) {
26122617
var self = this,
2613-
next = self.slides[self.currPos + 1],
2614-
prev = self.slides[self.currPos - 1];
2618+
prev,
2619+
next;
2620+
2621+
if (self.group.length < 2) {
2622+
return;
2623+
}
2624+
2625+
next = self.slides[self.currPos + 1];
2626+
prev = self.slides[self.currPos - 1];
26152627

26162628
if (prev && prev.type === type) {
26172629
self.loadSlide(prev);
@@ -3029,7 +3041,7 @@
30293041
});
30303042

30313043
$.fancybox = {
3032-
version: "3.5.1",
3044+
version: "3.5.2",
30333045
defaults: defaults,
30343046

30353047
// Get current instance and execute a command.
@@ -4687,7 +4699,11 @@
46874699
}
46884700

46894701
self.timer = setTimeout(function() {
4690-
instance.jumpTo((instance.currIndex + 1) % instance.group.length);
4702+
if (!instance.current.opts.loop && instance.current.index == instance.group.length - 1) {
4703+
instance.jumpTo(0);
4704+
} else {
4705+
instance.next();
4706+
}
46914707
}, current.opts.slideShow.speed);
46924708
}
46934709
} else {
@@ -4715,7 +4731,7 @@
47154731

47164732
if (current) {
47174733
self.$button
4718-
.attr("title", current.opts.i18n[current.opts.lang].PLAY_STOP)
4734+
.attr("title", (current.opts.i18n[current.opts.lang] || current.opts.i18n.en).PLAY_STOP)
47194735
.removeClass("fancybox-button--play")
47204736
.addClass("fancybox-button--pause");
47214737

@@ -4736,7 +4752,7 @@
47364752
self.clear();
47374753

47384754
self.$button
4739-
.attr("title", current.opts.i18n[current.opts.lang].PLAY_START)
4755+
.attr("title", (current.opts.i18n[current.opts.lang] || current.opts.i18n.en).PLAY_START)
47404756
.removeClass("fancybox-button--pause")
47414757
.addClass("fancybox-button--play");
47424758

dist/jquery.fancybox.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery.fancybox.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@fancyapps/fancybox",
33
"description": "Touch enabled, responsive and fully customizable jQuery lightbox script",
4-
"version": "3.5.1",
4+
"version": "3.5.2",
55
"homepage": "https://fancyapps.com/fancybox/3/",
66
"main": "dist/jquery.fancybox.js",
77
"style": "dist/jquery.fancybox.css",

src/css/core.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ body.compensate-for-scrollbar {
235235

236236
.fancybox-slide--video .fancybox-content,
237237
.fancybox-slide--map .fancybox-content,
238+
.fancybox-slide--pdf .fancybox-content,
238239
.fancybox-slide--iframe .fancybox-content {
239240
height: 100%;
240241
overflow: visible;
@@ -618,6 +619,10 @@ body.compensate-for-scrollbar {
618619
padding: 6px 0;
619620
}
620621

622+
.fancybox-close-small {
623+
right: -6px;
624+
}
625+
621626
.fancybox-slide--image .fancybox-close-small {
622627
background: #4e4e4e;
623628
color: #f2f4f6;

src/js/core.js

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@
632632
// ============================================================
633633

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

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

17721773
// Check if need to show loading icon
1773-
requestAFrame(function() {
1774-
requestAFrame(function() {
1775-
var $img = slide.$image;
1774+
setTimeout(function() {
1775+
var $img = slide.$image;
17761776

1777-
if (!self.isClosing && slide.isLoading && (!$img || !$img.length || !$img[0].complete) && !slide.hasError) {
1778-
self.showLoading(slide);
1779-
}
1780-
});
1781-
});
1777+
if (!self.isClosing && slide.isLoading && (!$img || !$img.length || !$img[0].complete) && !slide.hasError) {
1778+
self.showLoading(slide);
1779+
}
1780+
}, 50);
17821781

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

21082107
// Create temporary element marking original place of the content
@@ -2576,7 +2575,13 @@
25762575
.find("video,audio")
25772576
.filter(":visible:first")
25782577
.trigger("play")
2579-
.on("ended", $.proxy(self.next, self));
2578+
.one("ended", function() {
2579+
if (this.webkitExitFullscreen) {
2580+
this.webkitExitFullscreen();
2581+
}
2582+
2583+
self.next();
2584+
});
25802585
}
25812586

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

26012606
preload: function(type) {
26022607
var self = this,
2603-
next = self.slides[self.currPos + 1],
2604-
prev = self.slides[self.currPos - 1];
2608+
prev,
2609+
next;
2610+
2611+
if (self.group.length < 2) {
2612+
return;
2613+
}
2614+
2615+
next = self.slides[self.currPos + 1];
2616+
prev = self.slides[self.currPos - 1];
26052617

26062618
if (prev && prev.type === type) {
26072619
self.loadSlide(prev);

src/js/slideshow.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@
6464
}
6565

6666
self.timer = setTimeout(function() {
67-
instance.jumpTo((instance.currIndex + 1) % instance.group.length);
67+
if (!instance.current.opts.loop && instance.current.index == instance.group.length - 1) {
68+
instance.jumpTo(0);
69+
} else {
70+
instance.next();
71+
}
6872
}, current.opts.slideShow.speed);
6973
}
7074
} else {
@@ -92,7 +96,7 @@
9296

9397
if (current) {
9498
self.$button
95-
.attr("title", current.opts.i18n[current.opts.lang].PLAY_STOP)
99+
.attr("title", (current.opts.i18n[current.opts.lang] || current.opts.i18n.en).PLAY_STOP)
96100
.removeClass("fancybox-button--play")
97101
.addClass("fancybox-button--pause");
98102

@@ -113,7 +117,7 @@
113117
self.clear();
114118

115119
self.$button
116-
.attr("title", current.opts.i18n[current.opts.lang].PLAY_START)
120+
.attr("title", (current.opts.i18n[current.opts.lang] || current.opts.i18n.en).PLAY_START)
117121
.removeClass("fancybox-button--pause")
118122
.addClass("fancybox-button--play");
119123

0 commit comments

Comments
 (0)