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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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 id="Msg-0" class="js-button">Javascript Button 1</div>
<div id="Msg-1" class="js-button">Javascript Button 2</div>
<div id="Msg-0" class="jq-button">jQuery Button 1</div>
<div id="Msg-1" class="jq-button">jQuery Button 2</div>
<div id="Msg-0" class="nh-button">No Hook Button 1</div>
<div id="Msg-1" class="nh-button">No Hook Button 2</div>
              
            
!

CSS

              
                .js-button, .jq-button, .nh-button {
font-family: verdana,helvetica,arial;
font-size: 16px;
color: #6A6A6A; 
margin: 4px 6px 4px 0;
border: 1px solid #ffffff; 
cursor: pointer; 
padding: 8px 12px;
min-width: 60px; 
white-space: nowrap; 
border-radius: 5px; 
background-color: #E4E4E4;
text-align: center;
box-shadow: inset 2px 2px 6px -1px rgba(255,255,255,0.5), inset -2px -2px 6px -1px rgba(0,0,0,0.3);
text-shadow: 0px -1px 0px rgba(0,0,0,0.4),0px 1px 0px rgba(255,255,255,.6);
}
              
            
!

JS

              
                // separate file for user animations
import_animations = (function () {
	function _animations() {
			this.onBtnHover = {},
			//onBtnHover *********************************************
			this.onBtnHover.buttonHighlight = function (button, data) {
				var animation = 
					TweenLite.to(button, 0.3, {
						css : {
							color : data.autoStyle.textColor,
							backgroundColor : data.autoStyle.highColor,
							boxShadow : data.autoStyle.boxShadowButton,
							textShadow : data.autoStyle.textShadow
						},
						ease : Linear.easeNone,
						paused : true
					});
				
				return animation;
			},
			
			this.init = function () {
				return this;
			};
			
			return this.init();
	}

	return new _animations();
	
})();

// Vars *************
var ani = import_animations,

// Default property of global namespace that is merged with user to options.  User option defined as default for example purposes.
defaults = {
  onBtnHover: ani.onBtnHover.buttonHighlight //user hook
},
    
autoStyle = {textColor: "#ffffff", textShadow: "0px -1px 0px rgba(255,255,255,0.4),0px 1px 0px rgba(0,0,0,.6)", boxShadowButton: "inset 2px 2px 6px -1px rgba(255,255,255,0.5), inset -2px -2px 6px -1px rgba(0,0,0,0.3)", highColor: "#AA797D"},

data = {
		autoStyle : autoStyle
};
// jQuery version works
[].forEach.call(document.querySelectorAll(".jq-button"), function(el,i){ 
		el.animation = defaults.onBtnHover(el, data);
    console.log("jQuery");
    console.log(el.animation);
    jQuery(el).hover(function () {
				el.animation.play();
			}, function () {
				el.animation.reverse();
		});
});

// javascript equivalent does not
[].forEach.call(document.querySelectorAll(".js-button"), function(el,i){ 
		el.animation = defaults.onBtnHover(el, data); 
    console.log("javascript");
    console.log(el.animation);
		el.addEventListener("mouseenter", function () {
		  el.animation.play();
		});
		el.addEventListener("mouseleave", function () {
			el.animation.reverse();
		});  
});

// javascript works when not defining animation through hook
var buttonHighlight = function(button, data) {
	var animation = 
					TweenLite.to(button, 0.3, {
						css : {
							color : data.autoStyle.textColor,
							backgroundColor : data.autoStyle.highColor,
							boxShadow : data.autoStyle.boxShadowButton,
							textShadow : data.autoStyle.textShadow
						},
						ease : Linear.easeNone,
						paused : true
					});
	return animation;
};
// javascript works when not defining animation through hook
[].forEach.call(document.querySelectorAll(".nh-button"), function(el,i){ 
		el.animation = buttonHighlight(el, data);
    console.log("noHook");
    console.log(el.animation);
		el.addEventListener("mouseenter", function () {
		  el.animation.play();
		});
		el.addEventListener("mouseleave", function () {
			el.animation.reverse();
		});  
});
              
            
!
999px

Console