From b3cae863d1db717b4590bcb804198759533781ba Mon Sep 17 00:00:00 2001 From: ntr Date: Sat, 29 Jun 2019 15:38:56 +1000 Subject: [PATCH] hex --- client/assets/styles/game.css | 2 +- client/src/components/animations.jsx | 2 + client/src/components/anims/heal.jsx | 1 - client/src/components/anims/hex.jsx | 67 ++++++++++++++++++++++++++++ client/src/components/svgs/hex.jsx | 58 ------------------------ 5 files changed, 70 insertions(+), 60 deletions(-) create mode 100644 client/src/components/anims/hex.jsx delete mode 100644 client/src/components/svgs/hex.jsx diff --git a/client/assets/styles/game.css b/client/assets/styles/game.css index 53107eae..0495af41 100644 --- a/client/assets/styles/game.css +++ b/client/assets/styles/game.css @@ -72,7 +72,7 @@ "name " "stats "; - transition-property: translate; + transition-property: translate, opacity; transition-duration: 0.25s; transition-delay: 0; transition-timing-function: ease; diff --git a/client/src/components/animations.jsx b/client/src/components/animations.jsx index bcae6e36..22eef095 100644 --- a/client/src/components/animations.jsx +++ b/client/src/components/animations.jsx @@ -4,6 +4,7 @@ const AttackCharge = require('./anims/attack.charge'); const Blast = require('./anims/blast'); const Heal = require('./anims/heal'); +const Hex = require('./anims/hex'); const Strike = require('./anims/strike'); const Chaos = require('./anims/chaos'); const Slay = require('./anims/slay'); @@ -54,6 +55,7 @@ function animations(props) { case 'Chaos': return ; case 'Slay': return ; case 'Heal': return ; + case 'Hex': return ; case 'Siphon': return ; case 'SiphonTick': return ; default: return false; diff --git a/client/src/components/anims/heal.jsx b/client/src/components/anims/heal.jsx index 7e982ff1..63e2b2bb 100644 --- a/client/src/components/anims/heal.jsx +++ b/client/src/components/anims/heal.jsx @@ -41,7 +41,6 @@ class Heal extends Component { id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 400"> - // {this.charges} diff --git a/client/src/components/anims/hex.jsx b/client/src/components/anims/hex.jsx new file mode 100644 index 00000000..00ce204c --- /dev/null +++ b/client/src/components/anims/hex.jsx @@ -0,0 +1,67 @@ +const preact = require('preact'); +const { Component } = require('preact'); + +const anime = require('animejs').default; + +const { TIMES } = require('../../constants'); + +// shamelessly lifted from teh anime docs +// https://animejs.com/documentation/#svgAttr + +class Hex extends Component { + render(props) { + const { + id, + // stage, + // team, + // colour, + } = props; + + return ( + + + + + + + + + ); + } + + componentDidMount() { + anime({ + targets: ['.hex-anim polygon'], + points: '64 124.94732621931382 8.574 96.00354944613788 8.62269130211947 32.03166105954991 64 4 119.37730869788052 32.03166105954991 119.426 96.00354944613788', + direction: 'alternate', + easing: 'easeInOutExpo', + duration: TIMES.START_SKILL, + }); + + anime({ + targets: ['feTurbulence', 'feDisplacementMap'], + baseFrequency: 0, + scale: 1, + direction: 'alternate', + easing: 'easeInOutExpo', + duration: TIMES.START_SKILL, + }); + } + + // reset hexagon + componentWillUnmount() { + anime.set({ + targets: ['.hex-anim polygon'], + points: '64 124.94732621931382 8.574 96.00354944613788 8.62269130211947 32.03166105954991 64 4 119.37730869788052 32.03166105954991 119.426 96.00354944613788', + }); + } +} + +module.exports = Hex; diff --git a/client/src/components/svgs/hex.jsx b/client/src/components/svgs/hex.jsx deleted file mode 100644 index f914595a..00000000 --- a/client/src/components/svgs/hex.jsx +++ /dev/null @@ -1,58 +0,0 @@ -const preact = require('preact'); -const { Component } = require('preact'); - -const anime = require('animejs').default; - -// shamelessly lifted from teh anime docs -// https://animejs.com/documentation/#svgAttr - -class Hex extends Component { - render() { - return ( - - - - - - - - ); - } - - componentDidMount() { - anime({ - targets: ['.hex-anim'], - scale: [1, 2], - loop: true, - direction: 'alternate', - easing: 'easeInOutExpo', - }); - - anime({ - targets: ['.hex-anim polygon'], - points: '64 69.88600002141976 8.574 99.91603773440568 62.29420564057706 66.93105659089863 64 3.916037734405676 65.70579435942294 66.93105659089863 119.426 99.91603773440568', - loop: true, - direction: 'alternate', - easing: 'easeInOutExpo', - }); - - anime({ - targets: ['#hexFilter feTurbulence', '#hexFilter feDisplacementMap'], - baseFrequency: 0.05, - scale: 15, - loop: true, - direction: 'alternate', - easing: 'easeInOutExpo', - }); - } -} - -module.exports = Hex;