Skip to content
Merged
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Unreleased

- [Fields, images, placeholders and status marks](docs/guide/motion.md#replacing-content-in-place) cross-fade or turn when content changes in place. Outgoing marks keep their previous ink, and validation and accessible names update immediately. Includes iOS and Android recordings.
- [Fields, images, placeholders and status marks](docs/guide/motion.md#replacing-content-in-place) cross-fade or turn when content changes in place. Clearing a photo restores the avatar initials and releases the outgoing image. Outgoing marks keep their previous ink, and validation and accessible names update immediately. Includes iOS and Android recordings.
- Adopt Jolt 0.1.0-rc.22. [Web virtual lists](docs/components/virtual-list.md#reordering-a-thousand-rows-on-the-web) keep the dragged row mounted through a continuous reorder. Native speed dials align their panel with the visible trigger in wide rows and stay open when Android repeats a scroll notification for the same offset. Web layout exits preserve static form values, simple SVG and generated text. Gradients support endless playback, and desktop loops hold when their view detaches.

- AppBar, TabBar and SpeedDial accept `material="glass"` or a shared `chromeMaterial` theme setting. They use Liquid Glass on iOS 26+, system blur on earlier iOS versions, and backdrop filtering on supported browsers. The bars follow contrast and transparency preferences. [Material and recordings](docs/guide/platform-motion.md#chrome-material)
Expand Down
2 changes: 1 addition & 1 deletion docs/components/avatar.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Initials use the first letter of the first and last words; a single word produce

A photo appears only once it can paint: on Web the component waits for the image to decode, then fades it in while it eases from a slight zoom into its frame. NativeScript plays the same settle when the decoded image replaces the initials. Reduced motion keeps the fade and drops the zoom.

Changing `src` immediately restores the fallback. Stale results are ignored, including native results after unmount. Native requests already in flight may finish in the background: the component does not cancel the connection, implement its own cache or resize files before download. Supply appropriately sized images. There is no automatic retry; change `src` or remount to retry.
Clearing `src` fades the current photo back to the initials or icon, then releases the old image. Stale results are ignored, including native results after unmount. Native requests already in flight may finish in the background: the component does not cancel the connection, implement its own cache or resize files before download. Supply appropriately sized images. There is no automatic retry; change `src` or remount to retry.

Without a name or `accessibilityLabel`, the avatar is decorative. Inner images, initials and icons are not separately announced. There are no slots, events, image picker, upload or built-in action. Compose an appropriate, clearly named control for an action.

Expand Down
2 changes: 1 addition & 1 deletion docs/components/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Reserves space during loading and failure. Obsolete source results are ignored.

<<< @/../examples/catalog/shared/demos/ImageDemo.vue

`load` and `error` emit the source that completed. An empty source displays the fallback without starting a request. Explicit `height` takes precedence over the computed ratio; otherwise width and `aspectRatio` reserve the image space.
`load` and `error` emit the source that completed. An empty source displays the fallback without starting a request. If a photo was visible, it fades out and its image view is released. Explicit `height` takes precedence over the computed ratio; otherwise width and `aspectRatio` reserve the image space.

## Reveal

Expand Down
2 changes: 1 addition & 1 deletion docs/components/virtual-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ For a keyed shared-photo return, call `realizeKey({ key, tag, signal })` on the

## Rows of different heights

With `rowHeight="auto"` each row takes the height of its content: text that wraps, a picture whose size is known only once it loads, replies that open. Give `estimatedRowHeight` the height of a typical row; rows not measured yet count at that height, so the scroll bar can change length as you scroll.
With `rowHeight="auto"` each row takes the height of its content: text that wraps, a picture whose size is known only once it loads, replies that open. Give `estimatedRowHeight` the height of a typical row; rows not measured yet count at that height, so the scroll bar can change length as you scroll. On WebKit, a jump to a measured row uses the nearest scroll position the browser can represent, including when the preceding rows have fractional heights.

```vue
<MVirtualList
Expand Down
2 changes: 1 addition & 1 deletion docs/pt-BR/components/avatar.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ As iniciais usam a primeira letra da primeira e da última palavra; um nome de u

A foto só aparece quando já pode ser pintada: na Web o componente espera a imagem ser decodificada e então a revela com um fade, saindo de um zoom leve até se acomodar no quadro. No NativeScript o mesmo assentamento acontece quando a imagem decodificada substitui as iniciais. Com movimento reduzido, fica o fade e sai o zoom.

Trocar `src` volta imediatamente ao fallback. Resultados antigos são ignorados, inclusive após desmontar no nativo. Requisições nativas já iniciadas podem terminar em segundo plano: o componente não cancela a conexão, não define cache próprio e não redimensiona arquivos antes do download. Use imagens adequadas ao tamanho de exibição. Não há retry automático: altere `src` ou remonte o componente para tentar novamente.
Ao limpar `src`, a foto dá lugar às iniciais ou ao ícone e é removida ao fim da transição. Resultados antigos são ignorados, inclusive após desmontar no nativo. Requisições nativas já iniciadas podem terminar em segundo plano: o componente não cancela a conexão, não define cache próprio e não redimensiona arquivos antes do download. Use imagens adequadas ao tamanho de exibição. Não há retry automático: altere `src` ou remonte o componente para tentar novamente.

Sem nome nem `accessibilityLabel`, o avatar é decorativo. Imagem, iniciais e ícone internos não são anunciados separadamente. Não há slots, eventos, seletor de imagem, upload ou ação embutida. Para uma ação, componha o controle apropriado com um nome claro.

Expand Down
2 changes: 1 addition & 1 deletion docs/pt-BR/components/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Preserva o espaço durante carregamento e falha. Resultados de fontes antigas s

<<< @/../examples/catalog/shared/demos/ImageDemo.vue

`load` e `error` emitem a origem que terminou de carregar. Uma origem vazia mostra o fallback sem iniciar uma requisição. Se `height` estiver definido, ele tem prioridade sobre a proporção calculada; sem altura explícita, a largura e `aspectRatio` reservam o espaço.
`load` e `error` emitem a origem que terminou de carregar. Uma origem vazia mostra o fallback sem iniciar uma requisição. Se havia uma foto visível, ela desaparece gradualmente e o componente libera a imagem anterior. Se `height` estiver definido, ele tem prioridade sobre a proporção calculada; sem altura explícita, a largura e `aspectRatio` reservam o espaço.

## Revelação

Expand Down
2 changes: 1 addition & 1 deletion docs/pt-BR/components/virtual-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Para retornar a uma foto por chave, chame `realizeKey({ key, tag, signal })` na

## Linhas de alturas diferentes

Com `rowHeight="auto"`, cada linha fica com a altura do seu conteúdo: texto que quebra, uma imagem cujo tamanho só se sabe depois de carregar, respostas que se abrem. Passe em `estimatedRowHeight` a altura de uma linha típica; as linhas ainda não medidas contam com essa altura, então a barra de rolagem pode mudar de tamanho enquanto você rola.
Com `rowHeight="auto"`, cada linha fica com a altura do seu conteúdo: texto que quebra, uma imagem cujo tamanho só se sabe depois de carregar, respostas que se abrem. Passe em `estimatedRowHeight` a altura de uma linha típica; as linhas ainda não medidas contam com essa altura, então a barra de rolagem pode mudar de tamanho enquanto você rola. No WebKit, o salto até uma linha medida usa a posição de rolagem mais próxima que o navegador consegue representar, mesmo quando as linhas anteriores têm alturas fracionárias.

```vue
<MVirtualList
Expand Down
10 changes: 10 additions & 0 deletions examples/catalog/src/replacement-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ async function run() {
const text = (v: View) => (v instanceof Label ? String(v.text ?? '') : '')
const photo = () =>
tree(byId('replacement-image')).filter((v) => v instanceof Image && v.isLoaded && v.imageSource)
const avatar = () =>
tree(byId('replacement-avatar')).filter((v) => v instanceof Image && v.imageSource)
const labels = () => tree().map(text)
const update = await until(() => byId('replacement-change'))
await until(() => (photo().length ? true : undefined))
Expand All @@ -95,6 +97,8 @@ async function run() {
labels().filter((x) => /caption|Describe/.test(x)),
)
check('the replacement leaves one decoded photo', photo().length === 1, photo().length)
await until(() => avatar().length === 1 || undefined)
check('the avatar shows its decoded photo', avatar().length === 1, avatar().length)
check('the updated counter remains at ten', labels().includes('10'), '10')
const trigger = await until(() => control(/^Actions$/))
tap(trigger)
Expand Down Expand Up @@ -124,6 +128,12 @@ async function run() {
!byId('replacement-content') && !labels().includes('Add a caption'),
labels().filter((x) => /caption|Describe/.test(x)),
)
await until(() => avatar().length === 0 || undefined)
check(
'clearing the avatar releases the old photo and reveals the initials',
tree(byId('replacement-avatar')).some((v) => text(v) === 'AR'),
avatar().length,
)
// An actual ancestor scroll still dismisses the built-in popover.
let ancestor = trigger.parent
while (ancestor && !(ancestor instanceof ScrollView)) ancestor = ancestor.parent
Expand Down
37 changes: 20 additions & 17 deletions packages/desktop/src/components/MImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,26 @@ export const MImage = defineComponent({
},
{ flush: 'sync', immediate: true },
)
const handOver = () => {
const outgoing = held.value
const node = leaving.value
if (!outgoing || !node || host.reducedMotion()) {
held.value = undefined
return
}
const { exit } = replacementMotion(theme.value, 'fade')
away = host.motion(node).animate('opacity', 0, {
duration: exit.transition.duration,
ease: theme.value.motion.ease,
})
void away.finished.then(() => {
if (held.value === outgoing) held.value = undefined
})
}
watch(
[status, held],
([state, outgoing]) => {
if (state === 'loading' || !outgoing) return
const node = leaving.value
if (!node || host.reducedMotion()) {
held.value = undefined
return
}
const { exit } = replacementMotion(theme.value, 'fade')
away = host.motion(node).animate('opacity', 0, {
duration: exit.transition.duration,
ease: theme.value.motion.ease,
})
void away.finished.then(() => {
if (held.value === outgoing) held.value = undefined
})
},
{ flush: 'post' },
)
onBeforeUnmount(() => {
generation++
fade?.cancel()
Expand All @@ -84,7 +88,6 @@ export const MImage = defineComponent({
if (status.value === next) return
status.value = next
const crossing = held.value !== undefined
handOver()
if (!ready) {
emit('error', src)
return
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop/src/components/avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export const MAvatar = defineComponent({
{ flush: 'post', immediate: true },
)
watch(
settled,
(done) => {
[settled, held],
([done]) => {
const outgoing = held.value
const node = leaving.value
if (!done || !outgoing) return
Expand Down
4 changes: 2 additions & 2 deletions packages/nativescript/src/vue/components/MAvatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ export const MAvatar = defineComponent({
{ immediate: true },
)
watch(
() => image.value !== null || failed.value || !props.src.trim(),
(settled) => {
[() => image.value !== null || failed.value || !props.src.trim(), held],
([settled]) => {
if (!settled || !held.value) return
handed = held.value.key
handing.value = true
Expand Down
4 changes: 2 additions & 2 deletions packages/nativescript/src/vue/components/MImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export const MImage = defineComponent({
const image = shallowRef<ImageSource | null>(null)
const status = ref<'loading' | 'ready' | 'error'>('loading')
watch(
status,
(value) => {
[status, held],
([value]) => {
if (!held.value || value === 'loading') return
handed = held.value.key
handing.value = true
Expand Down
14 changes: 10 additions & 4 deletions packages/web/src/components/MAvatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
useHandover,
useMavisTheme,
} from '@getcortexlabs/mavis-core/vue'
import { useMotionContext } from '../motion-context.js'
import { useMotionSurface } from '../use-motion-surface.js'
import { avatarSizes, avatarInitials } from '@getcortexlabs/mavis-core'
import { webAttrs } from '../style.js'
Expand All @@ -21,7 +22,8 @@ export const MAvatar = defineComponent({
const ready = ref(false)
const failed = ref(false)
const photo = useAvatarPhoto(() => ready.value)
const motion = useMotionSurface(() => photo)
const context = useMotionContext()
const motion = useMotionSurface(() => photo, undefined, context)
// The photo shown before a new source stays until the next one decodes or fails.
const held = shallowRef<{ key: number; src: string }>()
const handing = ref(false)
Expand All @@ -31,7 +33,11 @@ export const MAvatar = defineComponent({
held.value = undefined
handing.value = false
})
const handoverMotion = useMotionSurface(() => (handing.value ? handover : undefined))
const handoverMotion = useMotionSurface(
() => (handing.value ? handover : undefined),
undefined,
context,
)
// Initials and photo cross: the initials fade out as a photo arrives and back as it leaves.
const fade = useFadeState(() => !ready.value && (!held.value || handing.value))
const initials = useMotionSurface(() => fade)
Expand All @@ -52,8 +58,8 @@ export const MAvatar = defineComponent({
{ flush: 'sync' },
)
watch(
() => ready.value || failed.value || !props.src.trim(),
(settled) => {
[() => ready.value || failed.value || !props.src.trim(), held],
([settled]) => {
if (!settled || !held.value) return
handed = held.value.key
handing.value = true
Expand Down
23 changes: 15 additions & 8 deletions packages/web/src/components/MImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ export const MImage = defineComponent({
held.value = undefined
handing.value = false
})
const handoverMotion = useMotionSurface(() => (handing.value ? handover : undefined))
const context = useMotionContext()
const handoverMotion = useMotionSurface(
() => (handing.value ? handover : undefined),
undefined,
context,
)
const status = ref<'loading' | 'ready' | 'error'>('loading')
const shared = useSharedTag(
() => (status.value === 'ready' ? props.sharedTag : undefined),
Expand All @@ -73,17 +78,19 @@ export const MImage = defineComponent({
releaseImage: (() => void) | undefined,
committing: string | undefined
const zooms = () => props.zoom > 1
const motion = useMotionSurface(() =>
status.value === 'ready' && !zooms() ? (props.motionSurface ?? reveal) : undefined,
const motion = useMotionSurface(
() => (status.value === 'ready' && !zooms() ? (props.motionSurface ?? reveal) : undefined),
undefined,
context,
)
const photo = shallowRef<HTMLImageElement>()
const syncPhoto = () => {
photo.value = status.value === 'ready' && zooms() ? currentImage : undefined
}
watch(status, syncPhoto, { flush: 'post' })
watch(
status,
(value) => {
[status, held],
([value]) => {
if (!held.value || value === 'loading') return
handed = held.value.key
handing.value = true
Expand All @@ -104,7 +111,7 @@ export const MImage = defineComponent({
void nextTick(syncPhoto)
},
)
useConnectedMotion(photo, useMotionContext(), (runtime, target) => {
useConnectedMotion(photo, context, (runtime, target) => {
const image = target as HTMLImageElement
const zoom = runtime.zoomable(image, {
viewport: image.parentElement!,
Expand Down Expand Up @@ -246,7 +253,7 @@ export const MImage = defineComponent({
width: '100%',
height: '100%',
objectFit: props.fit,
opacity: 1,
visibility: 'visible',
},
})
: null,
Expand Down Expand Up @@ -321,7 +328,7 @@ export const MImage = defineComponent({
width: '100%',
height: '100%',
objectFit: props.fit,
opacity: status.value === 'ready' ? 1 : 0,
visibility: status.value === 'ready' ? 'visible' : 'hidden',
},
})
: null,
Expand Down
5 changes: 4 additions & 1 deletion packages/web/src/components/MVirtualList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,11 @@ const VirtualList = defineComponent({
instance.update()
const list = root.value
if (list && Math.abs(list.scrollTop - top) >= 0.5) {
written = top
list.scrollTop = top
// Some WebKit hosts truncate fractional scrollTop even when row edges are fractional.
// Keep the closest available position so the preceding row does not peek over the edge.
if (Math.abs(list.scrollTop - top) > 0.5) list.scrollTop = Math.round(top)
written = list.scrollTop
}
}
/** Rows drawn off their logical place leave a gap or hide a row only at the ends. */
Expand Down
3 changes: 2 additions & 1 deletion packages/web/src/use-motion-surface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { reviveDetachedEffects } from './detached-effects.js'
export function useMotionSurface(
surface: () => MotionSurface | undefined,
plainText: () => boolean = () => false,
context = useMotionContext(),
) {
const element = shallowRef<HTMLElement>()
const connected = computed(() => (surface() ? element.value : undefined))
Expand All @@ -35,7 +36,7 @@ export function useMotionSurface(
}
useConnectedMotion(
connected,
useMotionContext(),
context,
(runtime, target) => {
// Responsive layout can resize a declared surface before an animation ends.
// Keep Jolt's geometry lease alive until every playback has been released.
Expand Down
3 changes: 2 additions & 1 deletion test/browser/adoption.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ test('forwards responsive image attributes and recovers when the chosen candidat
page,
}) => {
const image = page.locator('#adoption-image'),
inner = image.locator('img')
inner = image.getByAltText('Responsive sample', { exact: true })
await expect(inner).toHaveAttribute('srcset', /320w.*960w/)
await expect(inner).toHaveAttribute('sizes', '320px')
for (const [attribute, value] of [
Expand All @@ -126,6 +126,7 @@ test('forwards responsive image attributes and recovers when the chosen candidat
await expect(image).toHaveAttribute('data-state', 'error')
await page.getByRole('button', { name: 'Restore image source' }).click()
await expect(image).toHaveAttribute('data-state', 'ready')
await expect(image.locator('img')).toHaveCount(1)
expect(
await image.evaluate(
(el) => el.getBoundingClientRect().width / el.getBoundingClientRect().height,
Expand Down
5 changes: 4 additions & 1 deletion test/browser/item-motion.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ test('reduced motion settles every item gesture immediately', async ({ page }) =
await page.goto('/playground/#/components/avatar')
for (const name of ['Iniciais', 'Imagem indisponível', 'Imagem'])
await page.getByRole('button', { name, exact: true }).click()
await expect(page.locator('#avatar-preview img')).toHaveCSS('opacity', '1')
const avatar = page.locator('#avatar-preview')
await expect(avatar.locator('img:not([data-leaving])')).toBeVisible()
await expect(avatar.locator('img[data-leaving]')).toHaveCount(0)
await expect(avatar.locator('img')).toHaveCSS('opacity', '1')
expect(errors).toEqual([])
})
Loading
Loading