added fix for viewBox rotation bug
This commit is contained in:
parent
0cff31e65b
commit
12eb712fce
@ -1,35 +1,43 @@
|
|||||||
<!doctype html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<title>Flippable Doctest</title>
|
<title>Flippable Doctest</title>
|
||||||
<link rel="stylesheet" href="./3rdparty/highlight/styles/default.css">
|
<link rel="stylesheet" href="./3rdparty/highlight/styles/default.css" />
|
||||||
<link rel="stylesheet" href="../css/doctest.css">
|
<link rel="stylesheet" href="../css/doctest.css" />
|
||||||
<script src="./3rdparty/highlight/highlight.pack.js"></script>
|
<script src="./3rdparty/highlight/highlight.pack.js"></script>
|
||||||
<script src="../dist/iwmlib.3rdparty.js"></script>
|
<script src="../dist/iwmlib.3rdparty.js"></script>
|
||||||
<script src="../dist/iwmlib.js"></script>
|
<script src="../dist/iwmlib.js"></script>
|
||||||
|
|
||||||
<link rel="stylesheet" href="../css/flipeffect.css">
|
<link rel="stylesheet" href="../css/flipeffect.css" />
|
||||||
<template id="flipTemplate">
|
<template id="flipTemplate">
|
||||||
<div class="flipWrapper">
|
<div class="flipWrapper">
|
||||||
<div class="flipCard">
|
<div class="flipCard">
|
||||||
<div class="flipFace front"></div>
|
<div class="flipFace front"></div>
|
||||||
<div class="flipFace back" style="visibility:hidden;"></div>
|
<div class="flipFace back" style="visibility: hidden"></div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Very tricky problem to scale svgs: see https://css-tricks.com/scale-svg/ -->
|
<!-- Very tricky problem to scale svgs: see https://css-tricks.com/scale-svg/ -->
|
||||||
<svg class="flipButton backBtn" style="visibility:hidden;" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid meet">
|
<!-- SVG viewPort interferes with DOMMatrix calculations: see
|
||||||
<g stroke-width="8" stroke="white">
|
https://stackoverflow.com/questions/70696387/how-to-get-transform-matrix-of-a-dom-element-->
|
||||||
<circle cx="50" cy="50" r="44" fill="gray" />
|
<div class="flipButton backBtn" style="visibility:hidden;">
|
||||||
<line x1="30" y1="30" x2="70" y2="70" />
|
<svg viewBox="0 0 100 100" preserveAspectRatio="xMidYMid meet" style="width:inherit; height:inherit;">
|
||||||
<line x1="30" y1="70" x2="70" y2="30" />
|
<g stroke-width="8" stroke="white">
|
||||||
</g>
|
<circle cx="50" cy="50" r="44" fill="gray" />
|
||||||
</svg>
|
<line x1="30" y1="30" x2="70" y2="70" />
|
||||||
|
<line x1="30" y1="70" x2="70" y2="30" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<svg class="flipButton infoBtn" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid meet">
|
<div class="flipButton infoBtn">
|
||||||
<circle cx="50" cy="50" r="44" stroke="white" stroke-width="8" fill="gray" />
|
<svg viewBox="0 0 100 100" preserveAspectRatio="xMidYMid meet" style="width:inherit; height:inherit;">
|
||||||
<circle cx="50" cy="32" r="7" fill="white" />
|
<circle cx="50" cy="50" r="44" stroke="white" stroke-width="8" fill="gray" />
|
||||||
<line x1="50" y1="46" x2="50" y2="78" stroke="white" stroke-width="12" />
|
<circle cx="50" cy="32" r="7" fill="white" />
|
||||||
</svg>
|
<line x1="50" y1="46" x2="50" y2="78" stroke="white" stroke-width="12" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -46,6 +54,10 @@ via a HTML template that defines the placeholders for front and back views. The
|
|||||||
style file "css/flipeffect.css" holds reasonable default styles for this kind of
|
style file "css/flipeffect.css" holds reasonable default styles for this kind of
|
||||||
templates.
|
templates.
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
The SVG buttons have to be wrapped in an HTML DOM element which handles events. Otherwise,
|
||||||
|
the viewbox of the SVG will interfere with the coordinate transformation.
|
||||||
|
</p>
|
||||||
<pre><code>
|
<pre><code>
|
||||||
<template id="flipTemplate">
|
<template id="flipTemplate">
|
||||||
<div class="flipWrapper">
|
<div class="flipWrapper">
|
||||||
@ -59,27 +71,24 @@ templates.
|
|||||||
</template>
|
</template>
|
||||||
</code>
|
</code>
|
||||||
</pre>
|
</pre>
|
||||||
<h3>
|
<h3>Example</h3>
|
||||||
Example
|
<main id="main" style="border: 1px solid gray; position: relative; height: 256px"></main>
|
||||||
</h3>
|
<script class="doctest">
|
||||||
<main id="main" style="border: 1px solid gray; position: relative; height: 256px;" >
|
let scatterContainer = new DOMScatterContainer(main, { stopEvents: false })
|
||||||
|
if (Capabilities.supportsTemplate()) {
|
||||||
</main>
|
let flip = new DOMFlip(
|
||||||
<script class="doctest">
|
scatterContainer,
|
||||||
let scatterContainer = new DOMScatterContainer(main, {stopEvents: false})
|
flipTemplate,
|
||||||
if (Capabilities.supportsTemplate()) {
|
new ImageLoader('./examples/king.jpeg'),
|
||||||
|
new ImageLoader('./examples/women.jpeg'),
|
||||||
let flip = new DOMFlip(scatterContainer,
|
{ tapDelegateFactory: CardWrapper, preloadBack: true }
|
||||||
flipTemplate,
|
)
|
||||||
new ImageLoader('./examples/king.jpeg'),
|
flip.load().then((flip) => {
|
||||||
new ImageLoader('./examples/women.jpeg'),
|
flip.centerAt({ x: 150, y: 120 })
|
||||||
{ tapDelegateFactory: CardWrapper, preloadBack: true})
|
})
|
||||||
flip.load().then((flip) => {
|
} else {
|
||||||
flip.centerAt({ x: 150, y: 120})
|
alert('Templates not supported, use Edge, Chrome, Safari or Firefox.')
|
||||||
})
|
}
|
||||||
}
|
</script>
|
||||||
else {
|
</body>
|
||||||
alert("Templates not supported, use Edge, Chrome, Safari or Firefox.")
|
</html>
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
|
Loading…
Reference in New Issue
Block a user