JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<div class="area area-1">
<div class="inside inside-1">
<div class="content content-2"></div>
<div class="thing thing-1">Nothing</div>
</div>
<div class="count count-1">0</div>
</div>
<div class="area area-2">
<div class="inside inside-2">
<div class="content content-2"></div>
<div class="thing thing-2">Throttled</div>
</div>
<div class="count count-2">0</div>
</div>
<div class="area area-3">
<div class="inside inside-3">
<div class="content content-3"></div>
<div class="thing thing-3">Debounced</div>
</div>
<div class="count count-3">0</div>
</div>
* {
box-sizing: border-box;
}
body {
background: #eee;
}
.area {
width: 300px;
height: 200px;
margin: 20px auto;
background: white;
position: relative;
}
.inside {
height: 200px;
position: relative;
overflow: auto;
}
.content {
height: 5000px;
}
.thing {
position: absolute;
top: 0;
left: 0;
width: 100%;
text-align: center;
background: #f06d06;
color: white;
padding: 10px;
}
.count {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
// 1
var inside1 = $(".inside-1");
var thing1 = $(".thing-1");
var count1 = $(".count-1");
inside1.on('scroll', function() {
thing1.css("top", inside1[0].scrollTop);
count1.html(parseInt(count1.html())+1);
});
// 2
var inside2 = $(".inside-2");
var thing2 = $(".thing-2");
var count2 = $(".count-2");
inside2.on('scroll', _.throttle(function() {
thing2.css("top", inside2[0].scrollTop);
count2.html(parseInt(count2.html())+1);
}, 150));
// 3
var inside3 = $(".inside-3");
var thing3 = $(".thing-3");
var count3 = $(".count-3");
inside3.on('scroll', _.debounce(function() {
thing3.css("top", inside3[0].scrollTop);
count3.html(parseInt(count3.html())+1);
}, 100));
Also see: Tab Triggers