Skip to content

Commit

Permalink
release 1.1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
henrygd committed Jun 7, 2024
1 parent 75f5dbc commit ab717f2
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 114 deletions.
71 changes: 34 additions & 37 deletions dist/bigger-picture.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,7 @@ function instance$1($$self, $$props, $$invalidate) {
for (const obj of arr) {
// create media element if it doesn't exist
if (!mediaElement) {
mediaElement = element((obj.type?.includes('audio')) ? 'audio' : 'video');
mediaElement = document.createElement((obj.type?.includes('audio')) ? 'audio' : 'video');

addAttributes(mediaElement, {
controls: true,
Expand All @@ -1742,22 +1742,22 @@ function instance$1($$self, $$props, $$invalidate) {
}

// add sources / tracks to media element
const el = element(tag);
const el = document.createElement(tag);

addAttributes(el, obj);

if (tag == 'source') {
listen(el, 'error', error => opts.onError?.(container, activeItem, error));
el.onError = error => opts.onError?.(container, activeItem, error);
}

append(mediaElement, el);
mediaElement.append(el);
}
};

appendToVideo('source', activeItem.sources);
appendToVideo('track', activeItem.tracks || []);
listen(mediaElement, 'canplay', () => $$invalidate(0, loaded = true));
append(node, mediaElement);
mediaElement.oncanplay = () => $$invalidate(0, loaded = true);
node.append(mediaElement);
};


Expand Down Expand Up @@ -1898,7 +1898,7 @@ function create_if_block(ctx) {
};
}

// (319:199) {:else}
// (311:199) {:else}
function create_else_block(ctx) {
let div;
let raw_value = (/*activeItem*/ ctx[6].html ?? /*activeItem*/ ctx[6].element.outerHTML) + "";
Expand All @@ -1922,7 +1922,7 @@ function create_else_block(ctx) {
};
}

// (319:165)
// (311:165)
function create_if_block_5(ctx) {
let iframe;
let current;
Expand Down Expand Up @@ -1955,7 +1955,7 @@ function create_if_block_5(ctx) {
};
}

// (319:104)
// (311:104)
function create_if_block_4(ctx) {
let video;
let current;
Expand Down Expand Up @@ -1988,7 +1988,7 @@ function create_if_block_4(ctx) {
};
}

// (319:4) {#if activeItem.img}
// (311:4) {#if activeItem.img}
function create_if_block_3(ctx) {
let imageitem;
let current;
Expand Down Expand Up @@ -2028,7 +2028,7 @@ function create_if_block_3(ctx) {
};
}

// (319:299) {#if activeItem.caption}
// (311:299) {#if activeItem.caption}
function create_if_block_2(ctx) {
let div;
let raw_value = /*activeItem*/ ctx[6].caption + "";
Expand Down Expand Up @@ -2063,7 +2063,7 @@ function create_if_block_2(ctx) {
};
}

// (308:43) {#key activeItem.i}
// (300:43) {#key activeItem.i}
function create_key_block(ctx) {
let div;
let current_block_type_index;
Expand Down Expand Up @@ -2194,7 +2194,7 @@ function create_key_block(ctx) {
};
}

// (319:554) {#if items.length > 1}
// (311:554) {#if items.length > 1}
function create_if_block_1(ctx) {
let div;
let raw_value = `${/*position*/ ctx[4] + 1} / ${/*items*/ ctx[0].length}` + "";
Expand Down Expand Up @@ -2351,7 +2351,6 @@ function instance($$self, $$props, $$invalidate) {
const open = options => {
$$invalidate(5, opts = options);
$$invalidate(8, inline = opts.inline);
const openItems = opts.items;

// add class to hide scroll if not inline gallery
if (!inline && html.scrollHeight > html.clientHeight) {
Expand All @@ -2374,27 +2373,26 @@ function instance($$self, $$props, $$invalidate) {
$$invalidate(7, smallScreen = container.w < 769);
$$invalidate(4, position = opts.position || 0);

// make array w/ dataset to work with
if (Array.isArray(openItems)) {
// array was passed
$$invalidate(0, items = openItems.map((item, i) => {
// override gallery position if needed
if (opts.el && opts.el === item.element) {
$$invalidate(4, position = i);
}
// set items
$$invalidate(0, items = []);

return { i, ...item };
}));
} else {
// nodelist / node was passed
$$invalidate(0, items = (openItems.length ? [...openItems] : [openItems]).map((element, i) => {
// override gallery position if needed
if (opts.el === element) {
$$invalidate(4, position = i);
}
for (let i = 0; i < (opts.items.length || 1); i++) {
let item = opts.items[i] || opts.items;

if ('dataset' in item) {
items.push({ element: item, i, ...item.dataset });
} else {
item.i = i;
items.push(item);

// set item to element for position check below
item = item.element;
}

return { element, i, ...element.dataset };
}));
// override gallery position if needed
if (opts.el && opts.el === item) {
$$invalidate(4, position = i);
}
}
};

Expand Down Expand Up @@ -2472,7 +2470,7 @@ function instance($$self, $$props, $$invalidate) {
/** loads / decodes image for item */
const loadImage = item => {
if (item.img) {
const image = element('img');
const image = document.createElement('img');
image.sizes = opts.sizes || `${calculateDimensions(item)[0]}px`;
image.srcset = item.img;
item.preload = true;
Expand Down Expand Up @@ -2547,13 +2545,12 @@ function instance($$self, $$props, $$invalidate) {
/** code to run on mount / destroy */
const containerActions = node => {
$$invalidate(19, container.el = node, container);
let removeKeydownListener;
let roActive;
opts.onOpen?.(container.el, activeItem);

// don't use keyboard events for inline galleries
if (!inline) {
removeKeydownListener = listen(globalThis, 'keydown', onKeydown);
globalThis.addEventListener('keydown', onKeydown);
}

// set up resize observer
Expand Down Expand Up @@ -2581,7 +2578,7 @@ function instance($$self, $$props, $$invalidate) {
return {
destroy() {
ro.disconnect();
removeKeydownListener?.();
globalThis.removeEventListener('keydown', onKeydown);
closing.set(false);

// remove class hiding scroll
Expand Down
2 changes: 1 addition & 1 deletion dist/bigger-picture.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/bigger-picture.min.mjs

Large diffs are not rendered by default.

71 changes: 34 additions & 37 deletions dist/bigger-picture.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,7 @@ function instance$1($$self, $$props, $$invalidate) {
for (const obj of arr) {
// create media element if it doesn't exist
if (!mediaElement) {
mediaElement = element((obj.type?.includes('audio')) ? 'audio' : 'video');
mediaElement = document.createElement((obj.type?.includes('audio')) ? 'audio' : 'video');

addAttributes(mediaElement, {
controls: true,
Expand All @@ -1742,22 +1742,22 @@ function instance$1($$self, $$props, $$invalidate) {
}

// add sources / tracks to media element
const el = element(tag);
const el = document.createElement(tag);

addAttributes(el, obj);

if (tag == 'source') {
listen(el, 'error', error => opts.onError?.(container, activeItem, error));
el.onError = error => opts.onError?.(container, activeItem, error);
}

append(mediaElement, el);
mediaElement.append(el);
}
};

appendToVideo('source', activeItem.sources);
appendToVideo('track', activeItem.tracks || []);
listen(mediaElement, 'canplay', () => $$invalidate(0, loaded = true));
append(node, mediaElement);
mediaElement.oncanplay = () => $$invalidate(0, loaded = true);
node.append(mediaElement);
};


Expand Down Expand Up @@ -1898,7 +1898,7 @@ function create_if_block(ctx) {
};
}

// (319:199) {:else}
// (311:199) {:else}
function create_else_block(ctx) {
let div;
let raw_value = (/*activeItem*/ ctx[6].html ?? /*activeItem*/ ctx[6].element.outerHTML) + "";
Expand All @@ -1922,7 +1922,7 @@ function create_else_block(ctx) {
};
}

// (319:165)
// (311:165)
function create_if_block_5(ctx) {
let iframe;
let current;
Expand Down Expand Up @@ -1955,7 +1955,7 @@ function create_if_block_5(ctx) {
};
}

// (319:104)
// (311:104)
function create_if_block_4(ctx) {
let video;
let current;
Expand Down Expand Up @@ -1988,7 +1988,7 @@ function create_if_block_4(ctx) {
};
}

// (319:4) {#if activeItem.img}
// (311:4) {#if activeItem.img}
function create_if_block_3(ctx) {
let imageitem;
let current;
Expand Down Expand Up @@ -2028,7 +2028,7 @@ function create_if_block_3(ctx) {
};
}

// (319:299) {#if activeItem.caption}
// (311:299) {#if activeItem.caption}
function create_if_block_2(ctx) {
let div;
let raw_value = /*activeItem*/ ctx[6].caption + "";
Expand Down Expand Up @@ -2063,7 +2063,7 @@ function create_if_block_2(ctx) {
};
}

// (308:43) {#key activeItem.i}
// (300:43) {#key activeItem.i}
function create_key_block(ctx) {
let div;
let current_block_type_index;
Expand Down Expand Up @@ -2194,7 +2194,7 @@ function create_key_block(ctx) {
};
}

// (319:554) {#if items.length > 1}
// (311:554) {#if items.length > 1}
function create_if_block_1(ctx) {
let div;
let raw_value = `${/*position*/ ctx[4] + 1} / ${/*items*/ ctx[0].length}` + "";
Expand Down Expand Up @@ -2351,7 +2351,6 @@ function instance($$self, $$props, $$invalidate) {
const open = options => {
$$invalidate(5, opts = options);
$$invalidate(8, inline = opts.inline);
const openItems = opts.items;

// add class to hide scroll if not inline gallery
if (!inline && html.scrollHeight > html.clientHeight) {
Expand All @@ -2374,27 +2373,26 @@ function instance($$self, $$props, $$invalidate) {
$$invalidate(7, smallScreen = container.w < 769);
$$invalidate(4, position = opts.position || 0);

// make array w/ dataset to work with
if (Array.isArray(openItems)) {
// array was passed
$$invalidate(0, items = openItems.map((item, i) => {
// override gallery position if needed
if (opts.el && opts.el === item.element) {
$$invalidate(4, position = i);
}
// set items
$$invalidate(0, items = []);

return { i, ...item };
}));
} else {
// nodelist / node was passed
$$invalidate(0, items = (openItems.length ? [...openItems] : [openItems]).map((element, i) => {
// override gallery position if needed
if (opts.el === element) {
$$invalidate(4, position = i);
}
for (let i = 0; i < (opts.items.length || 1); i++) {
let item = opts.items[i] || opts.items;

if ('dataset' in item) {
items.push({ element: item, i, ...item.dataset });
} else {
item.i = i;
items.push(item);

// set item to element for position check below
item = item.element;
}

return { element, i, ...element.dataset };
}));
// override gallery position if needed
if (opts.el && opts.el === item) {
$$invalidate(4, position = i);
}
}
};

Expand Down Expand Up @@ -2472,7 +2470,7 @@ function instance($$self, $$props, $$invalidate) {
/** loads / decodes image for item */
const loadImage = item => {
if (item.img) {
const image = element('img');
const image = document.createElement('img');
image.sizes = opts.sizes || `${calculateDimensions(item)[0]}px`;
image.srcset = item.img;
item.preload = true;
Expand Down Expand Up @@ -2547,13 +2545,12 @@ function instance($$self, $$props, $$invalidate) {
/** code to run on mount / destroy */
const containerActions = node => {
$$invalidate(19, container.el = node, container);
let removeKeydownListener;
let roActive;
opts.onOpen?.(container.el, activeItem);

// don't use keyboard events for inline galleries
if (!inline) {
removeKeydownListener = listen(globalThis, 'keydown', onKeydown);
globalThis.addEventListener('keydown', onKeydown);
}

// set up resize observer
Expand Down Expand Up @@ -2581,7 +2578,7 @@ function instance($$self, $$props, $$invalidate) {
return {
destroy() {
ro.disconnect();
removeKeydownListener?.();
globalThis.removeEventListener('keydown', onKeydown);
closing.set(false);

// remove class hiding scroll
Expand Down
Loading

0 comments on commit ab717f2

Please sign in to comment.