-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adjust lava lamp example sizing for mobile
- Loading branch information
Showing
2 changed files
with
32 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
# Skateboard Configurator | ||
|
||
Toggle full screen on mobile to see the example better. | ||
|
||
<live-code src="./example.html"></live-code> | ||
|
||
<script> | ||
// A small hack to scale the size of the demo to make it easier to view inside the live-code preview. | ||
const livecode = document.querySelector('live-code') | ||
if (window.innerWidth > 720) { | ||
// A small hack to scale the size of the demo to make it easier to view inside the live-code preview. | ||
const livecode = document.querySelector('live-code') | ||
|
||
const iframe = livecode.shadowRoot.querySelector('iframe') | ||
iframe.style.width = "200%" | ||
iframe.style.height = "200%" | ||
const iframe = livecode.shadowRoot.querySelector('iframe') | ||
iframe.style.width = "200%" | ||
iframe.style.height = "200%" | ||
|
||
const preview = livecode.shadowRoot.querySelector('.live-code-preview') | ||
preview.style.overflow = 'hidden' | ||
const preview = livecode.shadowRoot.querySelector('.live-code-preview') | ||
preview.style.overflow = 'hidden' | ||
|
||
requestAnimationFrame(function loop() { | ||
if (iframe.contentWindow.document?.body) { | ||
iframe.contentWindow.document.body.style.transformOrigin = 'top left' | ||
iframe.contentWindow.document.body.style.scale = 0.5 | ||
} | ||
requestAnimationFrame(loop) | ||
}) | ||
requestAnimationFrame(function loop() { | ||
if (iframe.contentWindow.document?.body) { | ||
iframe.contentWindow.document.body.style.transformOrigin = 'top left' | ||
iframe.contentWindow.document.body.style.scale = 0.5 | ||
} | ||
requestAnimationFrame(loop) | ||
}) | ||
} | ||
</script> |