Skip to content

Commit

Permalink
update how activeItemIsHtml is calculated
Browse files Browse the repository at this point in the history
update setResizeFunc
  • Loading branch information
henrygd committed Dec 28, 2023
1 parent fb538f2 commit fb513c2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/bigger-picture.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import ImageItem from './components/image.svelte'
import Iframe from './components/iframe.svelte'
import Video from './components/video.svelte'
import { get, writable } from 'svelte/store'
import { writable } from 'svelte/store'
import { closing } from './stores'
import { listen, element as createEl } from 'svelte/internal'
Expand Down Expand Up @@ -45,8 +45,9 @@
/** active item object */
let activeItem
/** true if activeItem is html */
let activeItemIsHtml
/** returns true if `activeItem` is html */
const activeItemIsHtml = () =>
!activeItem.img && !activeItem.sources && !activeItem.iframe
/** function set by child component to run when container resized */
let resizeFunc
Expand All @@ -62,10 +63,7 @@
$: if (items) {
// update active item when position changes
activeItem = items[position]
activeItemIsHtml = activeItem.hasOwnProperty('html')
if (isOpen) {
// clear child resize function if html
activeItemIsHtml && setResizeFunc(null)
// run onUpdate when items updated
opts.onUpdate?.(container.el, activeItem)
}
Expand Down Expand Up @@ -223,7 +221,7 @@
const scaleIn = (node) => {
let dimensions
if (activeItemIsHtml) {
if (activeItemIsHtml()) {
const bpItem = node.firstChild.firstChild
dimensions = [bpItem.clientWidth, bpItem.clientHeight]
} else {
Expand Down Expand Up @@ -283,7 +281,9 @@
container.h = entries[0].contentRect.height
smallScreen = container.w < 769
// run child component resize function
resizeFunc?.()
if (!activeItemIsHtml()) {
resizeFunc?.()
}
// run user defined onResize function
opts.onResize?.(container.el, activeItem)
}
Expand Down

0 comments on commit fb513c2

Please sign in to comment.