From c014fd1f5e3da9043752070550453b7ef466ca7b Mon Sep 17 00:00:00 2001 From: Timmy Willison <4timmywil@gmail.com> Date: Wed, 15 Jan 2020 20:06:34 -0500 Subject: [PATCH] docs(demo): add special rotation examples --- demo/Demo.tsx | 4 ++- demo/demo.css | 4 +++ demo/examples/DisabledYAxis.tsx | 2 +- demo/examples/Rotate.tsx | 57 +++++++++++++++++++++++++++++++++ demo/examples/Standard.tsx | 2 +- demo/index.tsx | 2 ++ 6 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 demo/examples/Rotate.tsx diff --git a/demo/Demo.tsx b/demo/Demo.tsx index 30055730..656d17d5 100644 --- a/demo/Demo.tsx +++ b/demo/Demo.tsx @@ -2,11 +2,12 @@ import React from 'react' interface Props { title: string + subtitle?: string code: React.ReactNode children: React.ReactNode } -export default function Demo({ title, code, children }: Props) { +export default function Demo({ title, subtitle, code, children }: Props) { return (
) diff --git a/demo/demo.css b/demo/demo.css index a3249476..f01c41e3 100644 --- a/demo/demo.css +++ b/demo/demo.css @@ -38,6 +38,10 @@ body { margin-bottom: 30px; border-radius: 5px; } +.demo p { + margin: 0 0 1em; + font-size: 18px; +} pre { border-radius: 5px; margin: 0 0 20px !important; diff --git a/demo/examples/DisabledYAxis.tsx b/demo/examples/DisabledYAxis.tsx index c2acf7ef..1a09d159 100644 --- a/demo/examples/DisabledYAxis.tsx +++ b/demo/examples/DisabledYAxis.tsx @@ -5,7 +5,7 @@ import Demo from '../Demo' const code ={`Panzoom(elem, { disableYAxis: true })`}
-export default function ContainInside() {
+export default function DisabledYAxis() {
const elem = useRef{`const panzoom = Panzoom(elem, {
+ setTransform: (_, { scale, x, y }) => {
+ panzoom.setStyle('transform', \`rotate($\{x / 20}deg) scale($\{scale}) translate($\{x}px, $\{y}px)\`)
+ }
+})`}
+)
+
+const code2 = {`Panzoom(elem)`}
+
+export default function Rotate() {
+ const elem = useRef