From 20710e59673eb58375b64ad5908f6504bd670402 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 9 Aug 2021 17:48:06 +0800 Subject: [PATCH 1/6] add demo for random align --- examples/simple.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/examples/simple.js b/examples/simple.js index 4adac23..1adf289 100644 --- a/examples/simple.js +++ b/examples/simple.js @@ -1,6 +1,8 @@ import React, { Component } from 'react'; import Align from '../src'; +const allPoints = ['tl', 'tc', 'tr', 'cl', 'cc', 'cr', 'bl', 'bc', 'br']; + class Test extends Component { state = { monitor: true, @@ -62,6 +64,18 @@ class Test extends Component { })); }; + randomAlign = () => { + const randomPoints = []; + randomPoints.push(allPoints[Math.floor(Math.random() * 100) % allPoints.length]); + randomPoints.push(allPoints[Math.floor(Math.random() * 100) % allPoints.length]); + console.log(randomPoints); + this.setState({ + align: { + points: randomPoints, + }, + }); + }; + forceAlign = () => { this.$align.forceAlign(); }; @@ -91,6 +105,10 @@ class Test extends Component { Resize Source     + +