simple Autumn falling leaves with GSAP
A Pen by Diaco M.Lotfollahi on CodePen.
/* eslint-disable @typescript-eslint/no-var-requires */ | |
import type { Plugin, HtmlTagDescriptor } from 'vite'; | |
const addStyle = (src): HtmlTagDescriptor => ({ | |
injectTo: 'head', | |
tag: 'link', | |
attrs: { rel: 'stylesheet', href: src }, | |
}); | |
const addScript = (src): HtmlTagDescriptor => ({ |
var REG = /^([^:/?#]+:)?(?:\/\/(([^/?#:]*)(?::(\d+))?))?(([^?#]*)(\?([^#]*))?)(#.*)?$/i; | |
function parseUrl(str) { | |
var res = REG.exec(str); | |
if (!res) return null; | |
return { | |
href: res[0], | |
protocol: res[1] || '', | |
host: res[2] || '', | |
hostname: res[3] || '', |
simple Autumn falling leaves with GSAP
A Pen by Diaco M.Lotfollahi on CodePen.
There aren't many falling leaf javascript simulations, so I decided to make one. It's surprisingly difficult to mimic leaf motion, and this is a fairly simple attempt. There are a few more tricks with wind and leaf paths that I would like to add.
Vanilla JS, no dependencies
A Pen by Sarah Higley on CodePen.
A Pen by Anya Melnyk on CodePen.
window.onerror = function (msg, url, lineNo, columnNo, error) { | |
var string = msg.toLowerCase(); | |
var substring = "script error"; | |
if (string.indexOf(substring) > -1){ | |
alert('Script Error: See Browser Console for Detail'); | |
} else { | |
var message = [ | |
'Message: ' + msg, | |
'URL: ' + url, | |
'Line: ' + lineNo, |
let hidden | |
let visibilityChange | |
if (typeof document.hidden !== 'undefined') { | |
hidden = 'hidden' | |
visibilityChange = 'visibilitychange' | |
} else if (typeof document.webkitHidden !== 'undefined') { | |
hidden = 'webkitHidden' | |
visibilityChange = 'webkitvisibilitychange' | |
} |
class Plog { | |
constructor (name) { | |
this.name = name | |
this.messages = [] | |
} | |
write (...texts) { | |
this.messages.push({ | |
texts, | |
time: Date.now() |
var Dialog = { | |
$$el: null, | |
$$resolve: null, | |
$$reject: null, | |
init: function () { | |
var self = this; | |
if (self.$$el) { | |
return self; | |
} |