Skip to content
Draft

Upgrade #1266

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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"tippy.js": "^6.3.7"
},
"devDependencies": {
"@patternslib/dev": "^3.8.1",
"@patternslib/dev": "^3.9.0-alpha.0",
"@patternslib/pat-content-mirror": "^4.0.1",
"@patternslib/pat-doclock": "^3.0.0",
"@patternslib/pat-shopping-cart": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/core/base.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe("pat-base: The Base class for patterns", function () {
});

it("requires that patterns that extend it provide an object of properties", function () {
expect(Base.extend).toThrowError(
expect(Base.extend).toThrow(
"Pattern configuration properties required when calling Base.extend"
);
});
Expand Down
2 changes: 1 addition & 1 deletion src/lib/depends_parse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("Depedency expression parser", function () {
it("Can not do order comparison to string", function () {
expect(function () {
parser.parse("foo<bar");
}).toThrowError('Expected number or whitespace but "b" found.');
}).toThrow('Expected number or whitespace but "b" found.');
});

it("Equality comparison with string", function () {
Expand Down
32 changes: 18 additions & 14 deletions src/pat/gallery/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ export default Base.extend({
return template;
},

pswp_options() {
return {
scaleMode: this.options.scaleMethod,
loop: this.options.loop,
slideshowDelay: this.options.delay,
hideAnimationDuration: this.options.effectDuration,
showAnimationDuration: this.options.effectDuration,
pinchToClose: false,
closeOnScroll: false,
// Fix reload on gallery close which was induced by a history back call.
history: false,
};
},

initialize_trigger() {
const image_wrapper_els = dom.querySelectorAllAndMe(
this.el,
Expand Down Expand Up @@ -108,28 +122,18 @@ export default Base.extend({
// Now - when all is set - prevent default action.
e.preventDefault();

// Get the index of the clicked gallery item in the list of images.
const index =
this.images
.map((it) => it.src)
.indexOf(
trigger_el.getAttribute("href") || trigger_el.getAttribute("src")
) || 0;

const options = {
// Get the index of the clicked gallery item in the list of images.
index: index,
scaleMode: this.options.scaleMethod,
loop: this.options.loop,
slideshowDelay: this.options.delay,
hideAnimationDuration: this.options.effectDuration,
showAnimationDuration: this.options.effectDuration,
pinchToClose: false,
closeOnScroll: false,
// Fix reload on gallery close which was induced by a history back call.
history: false,
};
const pswp_options = this.pswp_options();
pswp_options.index = index; // start at clicked image

const gallery = new PhotoSwipe(pswp_el, PhotoSwipeUI, this.images, options);
const gallery = new PhotoSwipe(pswp_el, PhotoSwipeUI, this.images, pswp_options);

const gallery_reinit_sizes_debouncer = utils.debounce(() => {
gallery.updateSize(true); // reinit Items
Expand Down
8 changes: 8 additions & 0 deletions src/pat/gallery/gallery.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ describe("pat-gallery", function () {
const spy_init_trigger = jest.spyOn(instance, "initialize_trigger");
const spy_init_gallery = jest.spyOn(instance, "initialize_gallery");

jest.spyOn(instance, "pswp_options").mockImplementation(function () {
return { getThumbBoundsFn: () => ({ x:0, y:0, w:100 }) };
});

await utils.timeout(1);

expect(spy_init_trigger).toHaveBeenCalled();
Expand Down Expand Up @@ -65,6 +69,10 @@ describe("pat-gallery", function () {
const spy_init_trigger = jest.spyOn(instance, "initialize_trigger");
const spy_init_gallery = jest.spyOn(instance, "initialize_gallery");

jest.spyOn(instance, "pswp_options").mockImplementation(function () {
return { getThumbBoundsFn: () => ({ x:0, y:0, w:100 }) };
});

await utils.timeout(1);

expect(spy_init_trigger).toHaveBeenCalledTimes(1);
Expand Down
10 changes: 5 additions & 5 deletions src/pat/zoom/zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ var zoom = {

init: function ($el, opts) {
return $el.each(function () {
var $block = $(this),
options = parser.parse($block, opts);
const $block = $(this);
const options = parser.parse($block, opts);

let $slider = $("<input/>", {
const $slider = $("<input/>", {
type: "range",
step: "any",
value: 1,
Expand All @@ -28,8 +28,8 @@ var zoom = {
},

onZoom: function (event) {
var $block = event.data;
$block.css("zoom", this.value);
const $block = event.data;
$block[0].style.zoom = this.value;
},
};

Expand Down
2 changes: 1 addition & 1 deletion src/pat/zoom/zoom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe("pat-zoom", function () {
pattern.init($block);
var $range = $block.prev();
$range.val("1.5");
$range.change();
$range.trigger("change");
// Fairly lax test so it passes in different browsers.
expect($block[0].style.zoom).toBe("1.5");
});
Expand Down
Loading
Loading