-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add option document and demo sample code (#200)
* docs: add options page * docs: add sample codes to demo * docs: unuse wheelinput when there is no option * docs: add svelte sample codes * docs: add vue sample codes
- Loading branch information
Showing
60 changed files
with
3,368 additions
and
1,057 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
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div> | ||
<p>You can change the value of the axis and apply it to the UI via the touch screen, mouse, or various other inputs.</p> | ||
<div id="delegateTarget"> | ||
<div id="uiWrapper"> | ||
<div class="ui"> | ||
<img src="../image/axes/logo.svg"/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const SUPPORT_TOUCH = "ontouchstart" in window; | ||
const delegateTarget = document.getElementById("delegateTarget"); | ||
const uiWrapper = document.getElementById("uiWrapper"); | ||
const uiWidth = uiWrapper.getBoundingClientRect().width; | ||
const uiHeight = uiWrapper.getBoundingClientRect().height; | ||
const ui = uiWrapper.querySelector(".ui"); | ||
|
||
// 1. Initialize eg.Axes | ||
const axes = new eg.Axes({ | ||
panX: { | ||
range: [0, uiWidth], | ||
bounce: 20 | ||
}, | ||
panY: { | ||
range: [0, uiHeight], | ||
bounce: 20 | ||
}, | ||
zoom: { | ||
range: [1, 5], | ||
bounce: 1 | ||
} | ||
}, { | ||
minimumDuration: 300 | ||
}); | ||
|
||
// 2. attach event handler | ||
axes.on({ | ||
"change": function (e) { | ||
var pos = e.pos; | ||
ui.style[eg.Axes.TRANSFORM] = | ||
`translate3d(${pos.panX}px, ${pos.panY}px, 0) scale(${pos.zoom})`; | ||
}, | ||
}); | ||
|
||
// 3. Initialize inputTypes and connect it | ||
axes.connect("panX panY", new eg.Axes.PanInput(delegateTarget)) | ||
axes.connect("panX panY", new eg.Axes.MoveKeyInput(delegateTarget, { | ||
scale: [5, -5] | ||
})).connect("zoom", SUPPORT_TOUCH ? | ||
new eg.Axes.PinchInput(delegateTarget) : | ||
new eg.Axes.WheelInput(delegateTarget)); | ||
|
||
// 4. move to position | ||
axes.setTo({panX: uiWidth/2 + 20, panY: uiHeight/2}); |
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React, { useEffect } from "react"; | ||
|
||
import { useAxes, PanInput, PinchInput, MoveKeyInput, WheelInput } from "@egjs/react-axes"; | ||
import Icon from "../../../static/img/demos/axes/logo.svg"; | ||
import "../../css/demos/axes.css"; | ||
|
||
export default function AxesDemo() { | ||
const { connect, setAxis, setTo, panX, panY, zoom } = useAxes( | ||
{ | ||
panX: { | ||
range: [0, 0], | ||
bounce: 20, | ||
}, | ||
panY: { | ||
range: [0, 0], | ||
bounce: 20, | ||
}, | ||
zoom: { | ||
range: [1, 5], | ||
bounce: 1, | ||
}, | ||
}, | ||
{ | ||
minimumDuration: 300, | ||
} | ||
); | ||
|
||
useEffect(() => { | ||
const SUPPORT_TOUCH = "ontouchstart" in window; | ||
const delegateTarget = document.getElementById("delegateTarget"); | ||
const uiWrapper = document.getElementById("uiWrapper"); | ||
const uiWidth = uiWrapper.getBoundingClientRect().width; | ||
const uiHeight = uiWrapper.getBoundingClientRect().height; | ||
|
||
setAxis({ | ||
panX: { | ||
range: [0, uiWidth], | ||
}, | ||
panY: { | ||
range: [0, uiHeight], | ||
}, | ||
}); | ||
connect("panX panY", new PanInput(delegateTarget)); | ||
connect("panX panY", new MoveKeyInput(delegateTarget, { scale: [5, -5] })); | ||
connect("zoom", SUPPORT_TOUCH ? new PinchInput(delegateTarget) : new WheelInput(delegateTarget)); | ||
|
||
setTo({ panX: uiWidth / 2, panY: uiHeight / 2 }); | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<p> | ||
You can change the value of the axis and apply it to the UI via the | ||
touch screen, mouse, or various other inputs. | ||
</p> | ||
<div id="delegateTarget"> | ||
<div id="uiWrapper"> | ||
<div className="ui" style={{ transform: `translate3d(${panX}px, ${panY}px, 0) scale(${zoom})` }}> | ||
<Icon style={{ height: "75px" }} /> | ||
</div> | ||
</div> | ||
</div> | ||
<div style={{ clear: "both" }}></div> | ||
</div> | ||
); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<script> | ||
import { onMount } from "svelte"; | ||
import { useAxes, PanInput, PinchInput, MoveKeyInput, WheelInput } from "@egjs/svelte-axes"; | ||
|
||
const { connect, setAxis, setTo, panX, panY, zoom } = useAxes( | ||
{ | ||
panX: { | ||
range: [0, 0], | ||
bounce: 20, | ||
}, | ||
panY: { | ||
range: [0, 0], | ||
bounce: 20, | ||
}, | ||
zoom: { | ||
range: [1, 5], | ||
bounce: 1, | ||
}, | ||
}, | ||
{ | ||
minimumDuration: 300, | ||
} | ||
); | ||
|
||
onMount(() => { | ||
const SUPPORT_TOUCH = "ontouchstart" in window; | ||
const delegateTarget = document.getElementById("delegateTarget"); | ||
const uiWrapper = document.getElementById("uiWrapper"); | ||
const uiWidth = uiWrapper.getBoundingClientRect().width; | ||
const uiHeight = uiWrapper.getBoundingClientRect().height; | ||
|
||
setAxis({ | ||
panX: { | ||
range: [0, uiWidth], | ||
}, | ||
panY: { | ||
range: [0, uiHeight], | ||
}, | ||
}); | ||
connect("panX panY", new PanInput(delegateTarget)); | ||
connect("panX panY", new MoveKeyInput(delegateTarget, { scale: [5, -5] })); | ||
connect("zoom", SUPPORT_TOUCH ? new PinchInput(delegateTarget) : new WheelInput(delegateTarget)); | ||
|
||
setTo({ panX: uiWidth / 2, panY: uiHeight / 2 }); | ||
}); | ||
</script> | ||
|
||
<div> | ||
<p> | ||
You can change the value of the axis and apply it to the UI via the | ||
touch screen, mouse, or various other inputs. | ||
</p> | ||
<div id="delegateTarget"> | ||
<div id="uiWrapper"> | ||
<div class="ui" style="transform: `translate3d(${panX}px, ${panY}px, 0) scale(${zoom})`"> | ||
<img src="../image/axes/logo.svg"/> | ||
</div> | ||
</div> | ||
</div> | ||
<div style="clear: 'both'"></div> | ||
</div> |
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<template> | ||
<div class="App"> | ||
<p> | ||
You can change the value of the axis and apply it to the UI via the | ||
touch screen, mouse, or various other inputs. | ||
</p> | ||
<div id="delegateTarget"> | ||
<div id="uiWrapper"> | ||
<div class="ui" :style="{transform: `translate3d(${panX}px, ${panY}px, 0) scale(${zoom})`}"> | ||
<img :src="`${require('../../../static/img/demos/axes/logo.svg')}`"/> | ||
</div> | ||
</div> | ||
</div> | ||
<div style="clear: 'both'"></div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent, onMounted } from "vue"; | ||
import { useAxes, PanInput, PinchInput, MoveKeyInput, WheelInput } from "@egjs/vue-axes"; | ||
|
||
export default defineComponent({ | ||
name: "App", | ||
setup() { | ||
const { connect, setAxis, setTo, panX, panY, zoom } = useAxes( | ||
{ | ||
panX: { | ||
range: [0, 0], | ||
bounce: 20, | ||
}, | ||
panY: { | ||
range: [0, 0], | ||
bounce: 20, | ||
}, | ||
zoom: { | ||
range: [1, 5], | ||
bounce: 1, | ||
}, | ||
}, | ||
{ | ||
minimumDuration: 300, | ||
} | ||
); | ||
|
||
onMounted(() => { | ||
const SUPPORT_TOUCH = "ontouchstart" in window; | ||
const delegateTarget = document.getElementById("delegateTarget"); | ||
const uiWrapper = document.getElementById("uiWrapper"); | ||
const uiWidth = uiWrapper.getBoundingClientRect().width; | ||
const uiHeight = uiWrapper.getBoundingClientRect().height; | ||
|
||
setAxis({ | ||
panX: { | ||
range: [0, uiWidth], | ||
}, | ||
panY: { | ||
range: [0, uiHeight], | ||
}, | ||
}); | ||
connect("panX panY", new PanInput(delegateTarget)); | ||
connect("panX panY", new MoveKeyInput(delegateTarget, { scale: [5, -5] })); | ||
connect("zoom", SUPPORT_TOUCH ? new PinchInput(delegateTarget) : new WheelInput(delegateTarget)); | ||
|
||
setTo({ panX: uiWidth / 2, panY: uiHeight / 2 }); | ||
}); | ||
|
||
return { | ||
panX, | ||
panY, | ||
zoom, | ||
}; | ||
}, | ||
}); | ||
</script> |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<div> | ||
<p>You can create a viewer that can rotate 360 degrees using one axis.</p> | ||
<div class="car_spot"> | ||
<div class="car_rotate"> | ||
<div class="img_cont" style="position:relative;z-index:10"> | ||
<img height="150" src="./../image/car360/beatle (1).png"> | ||
<img height="150" src="./../image/car360/beatle (2).png" style="display:none;"> | ||
<img height="150" src="./../image/car360/beatle (3).png" style="display:none;"> | ||
<img height="150" src="./../image/car360/beatle (4).png" style="display:none;"> | ||
<img height="150" src="./../image/car360/beatle (5).png" style="display:none;"> | ||
<img height="150" src="./../image/car360/beatle (6).png" style="display:none;"> | ||
<img height="150" src="./../image/car360/beatle (7).png" style="display:none;"> | ||
<img height="150" src="./../image/car360/beatle (8).png" style="display:none;"> | ||
<img height="150" src="./../image/car360/beatle (9).png" style="display:none;"> | ||
<img height="150" src="./../image/car360/beatle (10).png" style="display:none;"> | ||
<img height="150" src="./../image/car360/beatle (11).png" style="display:none;"> | ||
<img height="150" src="./../image/car360/beatle (12).png" style="display:none;"> | ||
<img height="150" src="./../image/car360/beatle (13).png" style="display:none;"> | ||
<img height="150" src="./../image/car360/beatle (14).png" style="display:none;"> | ||
<img height="150" src="./../image/car360/beatle (15).png" style="display:none;"> | ||
<img height="150" src="./../image/car360/beatle (16).png" style="display:none;"> | ||
<img height="150" src="./../image/car360/beatle (17).png" style="display:none;"> | ||
<img height="150" src="./../image/car360/beatle (18).png" style="display:none;"> | ||
<img height="150" src="./../image/car360/beatle (19).png" style="display:none;"> | ||
<img height="150" src="./../image/car360/beatle (20).png" style="display:none"> | ||
<img height="150" src="./../image/car360/beatle (21).png" style="display:none"> | ||
<img height="150" src="./../image/car360/beatle (22).png" style="display:none"> | ||
<img height="150" src="./../image/car360/beatle (23).png" style="display:none"> | ||
<img height="150" src="./../image/car360/beatle (24).png" style="display:none"> | ||
<img height="150" src="./../image/car360/beatle (25).png" style="display:none"> | ||
<img height="150" src="./../image/car360/beatle (26).png" style="display:none"> | ||
<img height="150" src="./../image/car360/beatle (27).png" style="display:none"> | ||
<img height="150" src="./../image/car360/beatle (28).png" style="display:none"> | ||
<img height="150" src="./../image/car360/beatle (29).png" style="display:none"> | ||
<img height="150" src="./../image/car360/beatle (30).png" style="display:none"> | ||
<img height="150" src="./../image/car360/beatle (31).png" style="display:none"> | ||
<img height="150" src="./../image/car360/beatle (32).png" style="display:none"> | ||
<img height="150" src="./../image/car360/beatle (33).png" style="display:none"> | ||
<img height="150" src="./../image/car360/beatle (34).png" style="display:none"> | ||
<img height="150" src="./../image/car360/beatle (35).png" style="display:none"> | ||
<img height="150" src="./../image/car360/beatle (36).png" style="display:none"> | ||
</div> | ||
<div class="ratate_bg"></div> | ||
</div> | ||
</div> | ||
</div> |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const images = Array.prototype.slice.call(document.querySelectorAll( | ||
".car_rotate img")); | ||
const imagesNum = images.length; | ||
const ape = 360 / imagesNum; // angle per each | ||
|
||
// 1. Initialize eg.Axes | ||
const axes = new eg.Axes({ | ||
angle: { | ||
range: [0, 360], | ||
circular: true | ||
} | ||
}, { | ||
deceleration: 0.01 | ||
}); | ||
|
||
// 2. attach event handler | ||
axes.on("change", ({pos}) => { | ||
const index = Math.min(Math.round(pos.angle % 360 / ape), imagesNum - 1); | ||
images.map((v, i) => { | ||
v.style.display = i === index ? "inline-block" : "none"; | ||
}); | ||
}); | ||
|
||
// 3. Initialize a inputType and connect it | ||
axes.connect("angle", new eg.Axes.PanInput(".car_rotate")); |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<script> | ||
import { onMount } from "svelte"; | ||
import { useAxes, PanInput } from "@egjs/svelte-axes"; | ||
|
||
const images = Array.from({length: 36}, (_, i) => i + 1); | ||
const { connect, angle } = useAxes( | ||
{ | ||
angle: { | ||
range: [0, 360], | ||
circular: true, | ||
} | ||
}, | ||
{ | ||
deceleration: 0.01, | ||
}, | ||
); | ||
|
||
onMount(() => { | ||
connect("angle", new PanInput(".car_rotate")); | ||
}); | ||
</script> | ||
|
||
<div> | ||
<p>You can create a viewer that can rotate 360 degrees using one axis.</p> | ||
<div class="car_spot"> | ||
<div class="car_rotate"> | ||
<div class="img_cont" style="position: 'relative', zIndex: 10"> | ||
{#each images as i} | ||
<img height="150" src="./../image/car360/beatle ({i}).png" style="display: {Math.floor(($angle % 360) / 10 + 1) === i ? 'inline-block' : 'none'}"> | ||
{/each} | ||
</div> | ||
<div class="ratate_bg"></div> | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.