mirror of
https://github.com/sky-systems/sky_phone.git
synced 2026-08-29 03:01:42 +00:00
FIX - stabilize homescreen dragging across scaling (#18)
* FIX - stabilize homescreen dragging across scaling Render the home drag preview in an unzoomed viewport portal and normalize FiveM CEF DOM geometry before hit testing and drop settling. Cover Chrome 103, fractional scaling, 4K, ultrawide, and non-16:9 viewport behavior. * FIX - Implement LB guest app layout and lifecycle bridge Ensure custom LB apps are properly sized and visible by applying the required CSS contract on initialization and upon receiving the 'componentsLoaded' signal. * FIX - match uppercase script tags in LB bridge test
This commit is contained in:
@@ -94,36 +94,99 @@ describe('Springboard page swipe contract', () => {
|
||||
expect(folderIconSource).toContain(':style="dragPointerStyle"')
|
||||
})
|
||||
|
||||
it('uses the same scale-aware in-phone drag path as widgets', () => {
|
||||
expect(viewSource).not.toContain('source.cloneNode(true)')
|
||||
expect(viewSource).not.toContain('<Teleport to="body">')
|
||||
expect(viewSource).not.toContain(':external-drag-visual')
|
||||
it('renders the home drag visual through the unzoomed phone portal', () => {
|
||||
expect(viewSource).toContain('source.cloneNode(true)')
|
||||
expect(viewSource).toContain(
|
||||
"'springboard--home-dragging': draggingHomeApp !== null",
|
||||
'<Teleport defer to="#phone-home-drag-portal">',
|
||||
)
|
||||
expect(viewSource).toContain('draggedElement?.getBoundingClientRect()')
|
||||
expect(appIconSource).not.toContain('externalDragVisual')
|
||||
expect(folderIconSource).not.toContain('externalDragVisual')
|
||||
expect(mainCss).not.toContain('.home-drag-layer')
|
||||
expect(mainCss).not.toContain('.home-drag-ghost')
|
||||
expect(mainCss).not.toContain('.app-icon-item--drag-source')
|
||||
expect(viewSource).toContain(
|
||||
'<div ref="homeDragLayer" class="home-drag-layer" aria-hidden="true"></div>',
|
||||
)
|
||||
expect(viewSource).toContain('readPhoneViewportGeometry')
|
||||
expect(viewSource).toMatch(/const sourceBounds = \w+\.rect\(source\)/)
|
||||
expect(viewSource).toMatch(/const clipBounds = \w+\.rect\(\w+\)/)
|
||||
expect(viewSource).not.toContain('homeDragLocalPoint')
|
||||
expect(viewSource).not.toContain('springboardViewportToLocal')
|
||||
expect(viewSource).toContain("position.className = 'home-drag-position'")
|
||||
expect(viewSource).toMatch(
|
||||
/homeDragGrip = \{\s*x: event\.clientX - sourceBounds\.left,\s*y: event\.clientY - sourceBounds\.top,/,
|
||||
)
|
||||
expect(viewSource).toMatch(
|
||||
/ghost\.style\.transform = `scale\(\$\{\w+\.scaleX\}, \$\{\w+\.scaleY\}\)`/,
|
||||
)
|
||||
expect(
|
||||
viewSource.match(/:external-drag-visual="homeDragVisualActive"/g),
|
||||
).toHaveLength(4)
|
||||
expect(viewSource).toContain('updateHomeDragGhost(event)')
|
||||
expect(viewSource).toContain('const dropGhost = homeDragGhost')
|
||||
expect(viewSource).toContain('const dropOrigin = homeDragPreviewBounds')
|
||||
expect(viewSource).not.toContain('dropGhost?.getBoundingClientRect()')
|
||||
expect(viewSource).toContain('clearHomeDragGhost(dropGhost)')
|
||||
expect(viewSource).not.toContain('draggedElement?.getBoundingClientRect()')
|
||||
expect(viewSource).not.toContain('springboard--home-dragging')
|
||||
expect(appIconSource).toContain('externalDragVisual?: boolean')
|
||||
expect(folderIconSource).toContain('externalDragVisual?: boolean')
|
||||
expect(appIconSource).toContain('app-icon-item--drag-source')
|
||||
expect(folderIconSource).toContain('app-icon-item--drag-source')
|
||||
expect(mainCss).toMatch(
|
||||
/\.springboard--home-dragging \.springboard-page--apps\s*\{[^}]*overflow:\s*visible;/s,
|
||||
/\.phone-home-drag-portal\s*\{[^}]*pointer-events:\s*none;/s,
|
||||
)
|
||||
expect(mainCss).toContain('.home-drag-position')
|
||||
expect(mainCss).toContain('.home-drag-ghost')
|
||||
expect(mainCss).toContain('.app-icon-item--drag-source')
|
||||
expect(mainCss).toMatch(/\.springboard\s*\{[\s\S]*?overflow:\s*hidden;/)
|
||||
expect(mainCss).toMatch(
|
||||
/\.springboard-page--apps\s*\{[^}]*overflow:\s*hidden;/s,
|
||||
)
|
||||
})
|
||||
|
||||
it('cleans up the external drag visual on every terminal path', () => {
|
||||
expect(
|
||||
viewSource.match(
|
||||
/@dragstart="startHomeDrag\('(grid|dock)', [^,]+, \$event\)"/g,
|
||||
),
|
||||
).toHaveLength(4)
|
||||
expect(viewSource.match(/@dragcancel="stopHomeDrag"/g)).toHaveLength(4)
|
||||
expect(viewSource).toContain(
|
||||
'if (expectedGhost && homeDragGhost !== expectedGhost) return',
|
||||
)
|
||||
expect(viewSource).toMatch(
|
||||
/if \(!dragged\) \{\s*clearHomeDragGhost\(\)\s*return/,
|
||||
)
|
||||
expect(viewSource).toMatch(
|
||||
/animateHomeItemDrop\(\s*draggedItem,\s*dropArea,\s*dropIndex,\s*dropOrigin,?\s*\)\.finally\(/,
|
||||
)
|
||||
expect(viewSource).toMatch(
|
||||
/function stopHomeDrag[\s\S]*?clearHomeDragGhost\(\)/,
|
||||
)
|
||||
expect(viewSource).toMatch(
|
||||
/if \(folderId\) \{[\s\S]*?clearHomeDragGhost\(\)/,
|
||||
)
|
||||
expect(viewSource).toMatch(
|
||||
/onBeforeUnmount\(\(\) => \{[\s\S]*?clearHomeDragGhost\(\)/,
|
||||
)
|
||||
})
|
||||
|
||||
it('targets the active visual page and lets grid or dock drags turn pages', () => {
|
||||
expect(viewSource).toContain(':data-home-page="page.page"')
|
||||
expect(viewSource).toContain(':data-home-target-offset="cell.targetOffset"')
|
||||
expect(viewSource).toContain('nearestGridDropTarget')
|
||||
expect(viewSource).toContain('moveHomeAppToGridPage')
|
||||
expect(viewSource).not.toContain("draggingHomeApp.value?.area === 'grid'")
|
||||
expect(viewSource).toContain('event.clientX < pageBounds.left')
|
||||
expect(viewSource).toContain('event.clientY > pageBounds.bottom')
|
||||
expect(viewSource).toContain('event.clientX < springboardBounds.left')
|
||||
expect(viewSource).toContain('event.clientY > springboardBounds.bottom')
|
||||
expect(viewSource).toContain('function homeDragViewportRect(')
|
||||
expect(viewSource).toContain('if (geometry) return geometry.rect(element)')
|
||||
expect(viewSource).toContain('homeDragViewportRect(pageElement, geometry)')
|
||||
expect(viewSource).toContain('homeDragViewportRect(springboard, geometry)')
|
||||
expect(viewSource).toContain('homeDragViewportRect(slot, geometry)')
|
||||
expect(viewSource).toContain('homeDragViewportRect(dock, geometry)')
|
||||
expect(viewSource).toMatch(
|
||||
/homeDragViewportRect\(\s*appElement,\s*readPhoneViewportGeometry\(appElement\),?\s*\)/,
|
||||
)
|
||||
expect(viewSource).toContain(
|
||||
'springboardBounds.left + (bounds.left - pageBounds.left)',
|
||||
)
|
||||
expect(viewSource).toContain('nearestSpringboardRectIndex')
|
||||
expect(viewSource).toContain("queueEdgePageTurn(lastHomePointer, 'app')")
|
||||
expect(viewSource).toContain("edgePageLocked = dragType === 'widget'")
|
||||
|
||||
Reference in New Issue
Block a user