Skip to content

Instantly share code, notes, and snippets.

🤓
Reading your blog posts

Šime Vidas simevidas

🤓
Reading your blog posts
View GitHub Profile
@simevidas
simevidas / finished-polyfill.js
Last active May 17, 2020 — forked from AdaRoseCannon/Finished polyfill.js
Animation.prototype.finished polyfill
View finished-polyfill.js
// only polyfill .finished in browsers that already support animate()
if (document.body.animate) {
// Chrome does not seem to expose the Animation constructor globally
if (typeof Animation === 'undefined') {
window.Animation = document.body.animate({}).constructor;
}
if (Animation.prototype.finished === undefined) {
Object.defineProperty(Animation.prototype, 'finished', {
View applyTemplate.js
const applyTemplate = (templateElement, data) => {
const element = templateElement.content.cloneNode(true);
const treeWalker = document.createTreeWalker(element, NodeFilter.SHOW_ELEMENT, () => NodeFilter.FILTER_ACCEPT);
while (treeWalker.nextNode()) {
const node = treeWalker.currentNode;
for (let bindAttr in node.dataset) {
if (bindAttr.startsWith('bind_')) {
let dataKey = node.dataset[bindAttr];
let bindKey = bindAttr.substr(5);
View perfect-plugin.html
<!doctype html>
<html>
<head>
<title>Tabs Demo!</title>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
.container {
margin-top: 20px;
}
View gist:6708899
<script>
if (screen.width <= 640) document.write('<meta name="viewport" content="width=device-width, initial-scale=1">');
</script>
View encoding.html
<head>
<script>document.write('<meta charset="utf-8">')</script>
</head>
<body>
<script>
document.body.innerHTML += "✓";
</script>
</body>
You can’t perform that action at this time.