Skip to content

Commit

Permalink
fix: fix svelte README
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed Jun 19, 2023
1 parent 4f7d4ce commit 6ddffb7
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
54 changes: 54 additions & 0 deletions packages/infinite-viewer/test/iframe.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<style>
html,
body,
#root,
.app {
position: relative;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
color: #333;
background: #fdfdfd;
}
.app {
transform-style: preserve-3d;
}
</style>
<div class="app">
<iframe id="iframe" width="100%" height="100%"></iframe>
</div>
<script src="../dist/infinite-viewer.js"></script>
<script>
const iframeWindow = iframe.contentWindow;
const iframeDocument = iframeWindow.document;
const iframeBody = iframeDocument.body;

iframeBody.innerHTML = `
<style>
.container {
width: 100%;
height: 100%;
}
.viewport {
position: relative;
width: 400px;
height: 600px;
background: #999;
}
</style>
<div class="container">
<div class="viewport">
</div>
</div>
`;
const viewer = new InfiniteViewer(
iframeBody.querySelector(".container"),
{
autoZoom: true,
},
);
</script>
14 changes: 14 additions & 0 deletions packages/svelte-infinite-viewer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,32 @@
<a href="https://github.com/daybrush/scena" target="_blank"><strong>Main Project</strong></a>
</p>


* [Simple Demo](https://stackblitz.com/edit/vitejs-vite-p14cgg?file=src%2Flib%2FCounter.svelte,src%2FApp.svelte&terminal=dev)


## ⚙️ Installation
### npm
```bash
$ npm install svelte-infinite-viewer
```

## 🚀 How to use
* The viewer's class name must be set globally and use `className` prop.

```html
<script>
import InfiniteViewer from "svelte-infinite-viewer";
</script>
<style>
:global(.viewer) {
width: 100%;
height: 100%;
}
.viewport {
width: 400px;
height: 600px;
}
```
```jsx
<InfiniteViewer
Expand Down

0 comments on commit 6ddffb7

Please sign in to comment.