Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <svg style="display:none;"><defs><path id="stempath" d="M45.263 56.325c-4.153 2.877-8.688 3.997-13.684 2.947-6.75-1.42-12.658-.133-17.343 5.274-.444.513-1.154.795-1.945.841 8.279-12.713 19.369-20.347 35.181-19.185-1.142-4.912-2.697-9.386-8.229-10.989 8.393-2.329 14.908.648 20.39 6.482 4.967-3.077 7.65-6.526 12.7-16.222 2.45 6.292 1.399 11.899-3.969 20.682 3.378 1.556 6.882 2.05 10.168.448 3.099-1.51 5.857-3.72 9.176-5.891-1.793 6.643-5.919 10.74-11.471 13.709-5.747 3.074-11.571 1.879-16.764.42l-9.355 19.685c-4.165-4.978-4.672-11.17-4.276-17.6l.219-.991-.798.39z"/></defs></svg>

<div class="main">
	<div class="sound"></div>
	<svg class="stem" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><use xlink:href="#stempath"></use></svg>
	<div class="tomato">
		<div id="timeline"></div>
	</div>
</div>

              
            
!

CSS

              
                $color1:#45ff45;
$color2:#21e521;
$color3:#ff4444;
$color4:#e52121;
$color5:#F2F2F2;

@function makelongshadow($color) {
  $val: 0px 0px $color;
  @for $i from 1 through 200 {
    $val: #{$val}, #{$i}px #{$i}px #{$color};
  }
  @return $val;
}

@mixin longshadow($color) {
  box-shadow: makelongshadow($color);
}

html, body {
	width:100%;
	height:100%;
	min-width:500px;
	min-height:500px;
}

body {
	background:$color5;
	background-image:url('http://reneroth.org/projects/codepen/bgs/FF5qM3y.jpg');
	background-size:cover;
  display: flex;
  justify-content: center;
  align-items: center;
}

.main {
	width:500px;
	height:500px;
	background:$color3;
	border-radius:100px;
  display: flex;
  justify-content: center;
  align-items: center;
	overflow:hidden;
	position:relative;
}

.tomato {
	width:300px;
	height:300px;
	background:$color3;
	border:15px solid $color5;
	border-radius:50%;
	@include longshadow($color4);
	overflow:hidden;
	cursor:ew-resize;
	position:relative;
	&::before, &::after {
		content:'';
		display:block;
		position:absolute;
	}
	&::before {
		width: 0;
		height: 0;
		border-style: solid;
		border-width: 0 10px 20px 10px;
		border-color: transparent transparent $color5 transparent;
		left:140px;
		top:180px;
	}
	&::after {
		content:'Pomodoro';
		color:$color5;
		font-family:Fredoka One;
		font-size:18px;
		width:100%;
		text-align:center;
		top:250px;
	}
}

.stem {
	z-index:2;
	width:310px;
	top:-56px;
	left:75px;
	height:auto;
	position:absolute;
	pointer-events:none;
	use {
		fill:$color2;
	}
}

#timeline {
	width:676px;
	height:50px;
	position:absolute;
	top:110px;
	left:150px;
	background:url('http://reneroth.org/projects/codepen/pomodoro.png') no-repeat;
	background-size:100% 100%;
	//transform:translateX(-315px);
}

.sound {
	&::after {
		content:'\f028';
		font-family:FontAwesome;
		color:$color5;
		font-size:30px;
	}
	&.mute::after {
		content:'\f026';
	}
	position:absolute;
	cursor:pointer;
	width:28px;
	top:50px;
	left:50px;
}
              
            
!

JS

              
                var $tl = $('#timeline');
var $tm = $('.tomato');
var isDragging = false;
var oldPosX = 0;
var pixelPos = 0;
var timePos = 0;
var pixelWidth = 630;
var secondsWidth = 25;
var timeMultiplier = 1000 * 60;
var tickSound = new Howl({
		urls: ['http://reneroth.org/projects/codepen/pomodoro_tick.ogg', 'http://reneroth.org/projects/codepen/pomodoro_tick.mp3'],
		loop: true,
	volume:0.5
});
var turnSound = new Howl({
		urls: ['http://reneroth.org/projects/codepen/pomodoro_turn.ogg', 'http://reneroth.org/projects/codepen/pomodoro_turn.mp3']
});
var isTickPlaying = false;
var turnSoundDist = 25 / 2;
var ringSound = new Howl({
		urls: ['http://reneroth.org/projects/codepen/pomodoro_ring.ogg', 'http://reneroth.org/projects/codepen/pomodoro_ring.mp3'],
		volume: 1.0
});

function renderTime() {
		$tl.css('transform', 'translateX(-' + pixelPos + 'px)');
		$tl.css('-ms-transform', 'translateX(-' + pixelPos + 'px)');
		$tl.css('-moz-transform', 'translateX(-' + pixelPos + 'px)');
		$tl.css('-webkit-transform', 'translateX(-' + pixelPos + 'px)');
}
$tm.mousedown(function(e) {
		e.preventDefault();
		isDragging = true;
});
var lastTurnPos = 0;
$(document).mousemove(function(e) {
		e.preventDefault();
		if (isDragging) {
				var moveX = e.pageX - oldPosX;
				pixelPos -= moveX;
				pixelPos = Math.max(0, Math.min(pixelPos, pixelWidth));
				timePos = Math.ceil(pixelPos * secondsWidth / pixelWidth * timeMultiplier);
				renderTime();
				if (moveX > 0) {
						lastTurnPos = e.pageX;
				}
				if (e.pageX - lastTurnPos < -turnSoundDist) {
						if (pixelPos < pixelWidth) {
								turnSound.play();
						}
						lastTurnPos = e.pageX;
				}
		} else {
				lastTurnPos = e.pageX;
		}
		oldPosX = e.pageX;
}).mouseup(function(e) {
		isDragging = false;
});

var lastTick = Date.now();

function doTick() {
		//requestAnimationFrame(doTick);
		setTimeout(doTick, 10); //setTimeout so the timer will continue running even if in the background
		var tickDuration = Date.now() - lastTick;
		lastTick = Date.now();
		if (isDragging || timePos <= 0) {
				if (isTickPlaying) {
						tickSound.stop();
						isTickPlaying = false;
				}
				return;
		}
		if (!isTickPlaying) {
				tickSound.play();
				isTickPlaying = true;
		}
		timePos -= tickDuration;
		timePos = Math.max(0, Math.min(timePos, secondsWidth * timeMultiplier));
		pixelPos = timePos / secondsWidth * pixelWidth / timeMultiplier;
		renderTime();
		if (timePos == 0) {
				wiggle($('.main'));
				ringSound.stop().play();
		}
}
doTick();

function wiggle(element) {

		/**************
			Rotation
		**************/
		TweenMax.fromTo(element, .07, {
				x: -4
		}, {
				x: 4,
				ease: Power1.easeInOut,
				yoyo: true,
				repeat: 21,
				onCompleteParams: [element],
				onComplete: resetWiggle
		});
}

function resetWiggle(element) {
		TweenMax.to(element, .05, {
				x: 0,
				ease: Power1.easeInOut
		});
}

$('.sound').click(function(e) {
	e.preventDefault();
	if($(this).hasClass('mute')) {
		$(this).removeClass('mute');
		tickSound.volume(0.5);
	} else {
		$(this).addClass('mute');
		tickSound.volume(0.0);
	}
});
              
            
!
999px

Console