Skip to content

Commit

Permalink
Fix QuickLook (#1497)
Browse files Browse the repository at this point in the history
* fix iosSrc

* added iosSrc test
  • Loading branch information
elalish authored Sep 2, 2020
1 parent 6912c16 commit 080e8db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/model-viewer/src/features/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,17 @@ configuration or device capabilities');
* iOS can intent to their AR Quick Look.
*/
[$openIOSARQuickLook]() {
const modelUrl = new URL(this.src!, self.location.toString());
const modelUrl = new URL(this.iosSrc!, self.location.toString());
if (this.arScale === 'fixed') {
modelUrl.hash = 'allowsContentScaling=0';
}
const anchor = this[$arAnchor];
anchor.setAttribute('rel', 'ar');
anchor.appendChild(document.createElement('img'));
const img = document.createElement('img');
anchor.appendChild(img);
anchor.setAttribute('href', modelUrl.toString());
anchor.click();
anchor.removeChild(img);
}
}

Expand Down
2 changes: 2 additions & 0 deletions packages/model-viewer/src/test/features/ar-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,15 @@ suite('ModelViewerElementBase with ARMixin', () => {
suite('openQuickLook', () => {
test('sets hash for fixed scale', () => {
element.src = 'https://example.com/model.gltf';
element.iosSrc = 'https://example.com/model.usdz';
element.arScale = 'fixed';
(element as any)[$openIOSARQuickLook]();

expect(intentUrls.length).to.be.equal(1);

const url = new URL(intentUrls[0]);

expect(url.pathname).equal('/model.usdz');
expect(url.hash).to.equal('#allowsContentScaling=0');
});
});
Expand Down

0 comments on commit 080e8db

Please sign in to comment.