From 5b1a5be19623af5cd1c72a639a87da41d661b2d1 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 10 Feb 2016 01:04:57 +0100 Subject: [PATCH] make Buffy wink --- _src/_assets/javascripts/page-community.js | 15 ++++++ _src/_assets/styles/page-community.scss | 48 +++++++++++++------ .../svg}/buffy-with-stage.svg | 9 ++-- _src/community.html | 17 ++----- package.json | 3 +- 5 files changed, 60 insertions(+), 32 deletions(-) create mode 100644 _src/_assets/javascripts/page-community.js rename _src/{_assets/images => _includes/svg}/buffy-with-stage.svg (93%) diff --git a/_src/_assets/javascripts/page-community.js b/_src/_assets/javascripts/page-community.js new file mode 100644 index 0000000..8caefaf --- /dev/null +++ b/_src/_assets/javascripts/page-community.js @@ -0,0 +1,15 @@ + +//=include ../../../node_modules/is-in-viewport/lib/isInViewport.js + +jQuery(function($) { + + // start Buffy animation when in viewport + var buffy = $('#buffy'); + + if (buffy.isInViewport() ) { + buffy.addClass('is-ready'); + } else { + buffy.removeClass('is-ready'); + } + +}); diff --git a/_src/_assets/styles/page-community.scss b/_src/_assets/styles/page-community.scss index 6e9bde7..86b76f8 100644 --- a/_src/_assets/styles/page-community.scss +++ b/_src/_assets/styles/page-community.scss @@ -10,12 +10,8 @@ } } -.section-community, -.section-conduct { - @extend .text-center; -} - .section-community { + @extend .text-center; position: relative; // make room for BuffyDB padding-bottom: 200px; @@ -33,15 +29,6 @@ margin-top: 0; } - .buffy { - @extend .img--responsive; - vertical-align: bottom; - height: 220px; - position: absolute; - bottom: 0; - right: 0; - } - .social-link { &, .icon { @@ -79,3 +66,36 @@ } } } + + +// +// Buffy: positioned and animated +// +#buffy { + @extend .img--responsive; + vertical-align: bottom; + height: 220px; + position: absolute; + bottom: 0; + right: 0; + + #arm { + transform-origin: right; + } + + &.is-ready { + #arm { + animation: buffy-wink 1s ease-in-out 3s; + } + } + + &:hover #arm { + animation: buffy-wink 1s ease-in-out; + } +} + +@keyframes buffy-wink { + 0% { transform: rotate(0); } + 25%, 50% { transform: rotate(-20deg); } + 30%, 100% { transform: rotate(0); } +} diff --git a/_src/_assets/images/buffy-with-stage.svg b/_src/_includes/svg/buffy-with-stage.svg similarity index 93% rename from _src/_assets/images/buffy-with-stage.svg rename to _src/_includes/svg/buffy-with-stage.svg index ae9e3bd..4394f71 100644 --- a/_src/_assets/images/buffy-with-stage.svg +++ b/_src/_includes/svg/buffy-with-stage.svg @@ -1,4 +1,4 @@ - + + {% include svg/buffy-with-stage.svg %} - - diff --git a/package.json b/package.json index 483f651..b84b8a1 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "normalize-opentype.css": ">=0.2.4", "parsleyjs": "^2.0.7", "svg4everybody": "^2.0.0", - "vivus": "^0.2.2" + "vivus": "^0.2.2", + "is-in-viewport": "^2.3.0" }, "devDependencies": { "browser-sync": ">=2.10.0",