Skip to content

Instantly share code, notes, and snippets.

View patsma's full-sized avatar
💭
Perfection is not attainable, but if we chase perfection we can catch excellence

Patryk Smakosz patsma

💭
Perfection is not attainable, but if we chase perfection we can catch excellence
View GitHub Profile
const svg = document.getElementById('scene').getSVGDocument();
const shape01 = svg.getElementById('shape-01');
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@patsma
patsma / Add filter to SVG
Created February 8, 2020 15:05
Dynamically add filter to your SVG
function setSvgAttrs() {
let svg = document.getElementsByTagName('svg')[0];
gsap.set(svg, {attr: {viewBox: '0 0 970 250'}});
const background01 = document.querySelector('#background01');
function createFilter() {
const svgns = "http://www.w3.org/2000/svg";
@patsma
patsma / cloudSettings
Last active June 21, 2021 12:45
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-12-07T07:27:29.821Z","extensionVersion":"v3.4.3"}
var element = document.querySelector(prompt('Insert the querySelector to the svg element.', '#gear'));
var bbox = element.getBBox(),
x = bbox.x,
y = bbox.y,
w = bbox.width,
h = bbox.height
;
var result =
'center center' + "\n" +
<div class="image-container-block">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/65984/photo-1413752567787-baa02dde3c65.jpg" alt="">
<div class="inner-image-block">
<div class="image-animate-border"></div>
</div>
</div>
<style>
</style>
.wpcf7 form input {
-webkit-user-select: text;
}
@patsma
patsma / txt
Created March 20, 2018 19:30
OP meta tags
http://ogp.me
Basic Metadata
To turn your web pages into graph objects, you need to add basic metadata to your page. We've based the initial version of the protocol on RDFa which means that you'll place additional <meta> tags in the <head> of your web page. The four required properties for every page are:
og:title - The title of your object as it should appear within the graph, e.g., "The Rock".
og:type - The type of your object, e.g., "video.movie". Depending on the type you specify, other properties may also be required.
og:image - An image URL which should represent your object within the graph.
og:url - The canonical URL of your object that will be used as its permanent ID in the graph, e.g., "http://www.imdb.com/title/tt0117500/".
As an example, the following is the Open Graph protocol markup for The Rock on IMDB:
@patsma
patsma / timeline.js
Created March 13, 2018 00:04
Toggle timeline held in function
var select = function(s){
return document.querySelector(s);
}
var normalTimelineGreen = select('.normalTimelineGreen');
var returnedTimelineRed = select('.returnedTimelineRed');
Some may find this confusing, but I like to tack .reverse() onto the end and toggle an animation like this...
var tl = new TimelineMax()
.to("#box", 0.25, { opacity: 0.5, scale: 0.75 })
.reverse();
$("#box").click(function() {
tl.reversed(!tl.reversed());
});
http://codepen.io/osublake/pen/9d46535fe6e5b5c8f577308a5ae1ea72