OFCN logo-avatar-anim

In this example below you will see how to do a OFCN logo-avatar-anim with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by kubasanitrak, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright kubasanitrak ©
  • HTML
  • CSS
  • JavaScript
    <div class="wrapper">
	<div class="logo">
		<div class="logo-part part-1"></div>
		<div class="logo-part part-2"></div>
	</div>
	<button>animate</button>
</div>

/*Downloaded from https://www.codeseek.co/kubasanitrak/ofcn-logo-avatar-anim-JZXxry */
    *, *::before, *::after {margin: 0; padding: 0; }
html {box-sizing: border-box} *, *::before, *::after {box-sizing: inherit}


@mixin bgc-offset($n, $color) { @for $i from 1 through $n { &:nth-child(#{$i}) { background-color: darken($color, 0% + ($i * 2)); } } } 
@mixin mq($point) {@if $point == mq-XL {@media screen and (min-width: 90.1rem) { @content; } } @else if $point == mq-L-UP {@media screen and (min-width: 48.1rem)  { @content; } } @else if $point == mq-M-UP {@media screen and (min-width: 40.1rem)  { @content; } } @else if $point == mq-S {@media screen and (max-width: 40rem)  { @content; } } @else if $point == mq-land {@media screen and (orientation: landscape)  { @content; } } @else if $point == mq-portr {@media screen and (orientation: portrait)  { @content; } } }

$logo-W: 5vw;
body {
	width: 100%;
	height: 100%;
}
.wrapper {
	width: 100%;
	min-height: 100vh;
	overflow: hidden;
	// padding: 20px;
}
.logo {
	width: $logo-W;
	position: relative;
	min-height: calc(#{$logo-W} / 100 * 45);
	// background-color: pink;
}
.logo-part {
	// margin-left: 20px;
	background-color: #000;
	height: calc(#{$logo-W} / 100 * 25);
	position: absolute;
}
.part-1 {
	width: 70%;
	margin-bottom: calc(-#{$logo-W} / 100 * 5);
}
.part-2 {
	width: 45%;
	top: calc(#{$logo-W} / 100 * 20);
}

button {
	position: absolute;
	top: 50px;
	right: 50px;
	z-index: 500;
	padding: 1rem;
}


/*Downloaded from https://www.codeseek.co/kubasanitrak/ofcn-logo-avatar-anim-JZXxry */
    // TweenMax.from(['.part-1', '.part-2'], 1, {ease: Bounce.easeOut, x: "-20", y: "-20", scale: 30, transformOrigin: "top left", repeat: -1, repeatDelay: 2});
var $scale = $(window).innerWidth() / $('.part-2').width();
console.log("scale: " + $scale);

var $pos = $('.part-2').position();
var $offsetY = $pos.top * $scale;

var $timing = 0.8;
// if($('.logo').height() * $scale < $(window).innerHeight()) {
// 	$scale = $(window).innerHeight() / $('.logo').height();
// }
/*
tlm = new TimelineMax();
tlm.set(['.part-1', '.part-2'], {scale: String($scale), transformOrigin: "top left", x: "-20", y: "-20"});
tlm.set('.part-2', {y: String($offsetY)});
tlm.to(['.part-1', '.part-2'], {scale: 1, ease: Power4.easeOut, x: 0, y: 0})
// tlm.pause();
// console.log("scale: " + $scale);
*/
$('body').on('click', 'button', function() {
	tlm.play();
// 	TweenMax.from('.part-1', 1, {ease: Power4.easeOut, scale: String($scale), transformOrigin: "top left", repeat: 2, repeatDelay: 2, yoyo: true});
// TweenMax.from('.part-2', 1, {ease: Power4.easeOut, scale: String($scale), y: String($offsetY), transformOrigin: "top left", repeat: 2, yoyo: true});
})
tlm = new TimelineMax({});

tlm
	// .from('.logo', $timing, {ease: Power4.easeOut, scale: String($scale), transformOrigin: "top left"}) 
.from('.part-2', $timing, {ease: Power4.easeOut, scale: String($scale), y: String($offsetY), transformOrigin: "top left"})
	.from('.part-1', $timing, {ease: Power4.easeOut, scale: String($scale), transformOrigin: "top left", delay: -$timing * 0.92 }) 
tlm.pause();

// tlm.to('.logo', 1, {ease: Power4.easeOut, scale: 0.8,  transformOrigin: "bottom right", delay: -0.5 });


Comments