Skip to content

Instantly share code, notes, and snippets.

@PixelPartner
Created October 17, 2018 16:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PixelPartner/dfcd10b8766c9d5d1e441b63811d5581 to your computer and use it in GitHub Desktop.
Save PixelPartner/dfcd10b8766c9d5d1e441b63811d5581 to your computer and use it in GitHub Desktop.
Define your own elm-ui Element that works with Safari AR Quicklook feature on iOS 12+
{-
Define your own elm-ui Element that works with Safari AR Quicklook feature on iOS 12+
The problem with the standard Element nodes is that Safari wants the <a> node to only have
a single child and that needs to be an <img>
-}
usdz : List (Attribute Msg) -> { usdzUrl : String, imgUrl : String } -> Element Msg
usdz attrs rec =
link
( htmlAttribute (Html.Attributes.attribute "rel" "ar")
:: attrs
)
{ label= html
(Html.node "img"
[ Html.Attributes.src rec.imgUrl
, Html.Attributes.style "max-width" "100%"
, Html.Attributes.style "max-height" "100%"
]
[] -- no other content allowed here by Apple
)
, url=rec.usdzUrl
}
-- usage:
usdz [ width (px 240), centerX ]
{ usdzUrl="models/model1.usdz"
, imgUrl="img/model1_preview.png"
}
@PixelPartner
Copy link
Author

Also make sure, your web server serves .usdz files with the proper MIME type not included in most off-the-shelf Apache installs.
Look up the details on http://dev.apple.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment