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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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

              
                <div class="test-wrap">
	<div class="wave-text">He remembered the time he had hooked one of a pair of marlin. The male fish always let the female fish feed first and the hooked fish, the female, made a wild, panic-stricken, despairing fight that soon exhausted her, and all the time the male had stayed with her, crossing the line and circling with her on the surface. He had stayed so close that the old man was afraid he would cut the line with his tail which was sharp as a scythe and almost of that size and shape. When the old man had gaffed her and clubbed her, holding the rapier bill with its sandpaper edge and clubbing her across the top of her head until her colour turned to a colour almost like the backing of mirrors, and then, with the boy’s aid, hoisted her aboard, the male fish had stayed by the side of the boat. Then, while the old man was clearing the lines and preparing the harpoon, the male fish jumped high into the air beside the boat to see where the female was and then went down deep, his lavender wings, that were his pectoral fins, spread wide and all his wide lavender stripes showing. He was beautiful, the old man remembered, and he had stayed.</div>
</div>
              
            
!

CSS

              
                body{
	
}

.test-wrap{
	padding:4rem;
	max-width:740px;
	margin:auto;
}

.wave-text{
	
	.letter-wrap{
		position:relative;
		top:0;
		left:0;
		font-size:1.25rem;
		color:#326760;
		line-height:1.8rem;
	}
}
              
            
!

JS

              
                class WaveText{
	constructor(selector, run = true){
		console.log("WaveText!", selector);
		
		this.letters = [];
		let _this = this;
		this.sineId = 0;
		this.phaseProgress = 0.1;
		
		$(selector).each( (i, el) => {
			
			let 
				$el = $(el),
				$output = $el.text().split('').reduce( (prevLetter, letter, letterI) => {
					
					let $outputEl = $(`<span class="letter-wrap">${letter}</span>`);
					
					_this.letters.push({
						mag:0,
						id:_this.letters.length,
						$el:$outputEl,
						maxMag:Math.random() * 38 + 8
					});
					
					return prevLetter.append($outputEl);
				}, $(`<div class="wrap"></div>`))
			;
			
			$el.empty().append($output);
		});
		
		if(run === true) this.run();
	}
	
	run(){
		console.log("WaveText.run...");
		
		this.runIntervalId = setInterval( () => {
			// console.log('run:'+this.sineId);
			
			this.letters.forEach( (obj, i) => {
				
				obj.mag = Math.min(obj.mag += 0.005, obj.maxMag);
				
				let 
					rad = this.sineId +i*this.phaseProgress,
					cos = Math.cos(rad),
					sin = Math.sin(rad)
					// opacity = 1 - .35*(1 + sin)
			;
				obj.$el.css({
					left:obj.mag *cos,
					top:1.5 * obj.mag *sin,
					opacity:1 - .45*(1 + sin) *(obj.mag / obj.maxMag)
				});
			});
			
			this.sineId += .085;
		},30);
	}
}

var wave0 = new WaveText('.wave-text', true);

              
            
!
999px

Console