Skip to content

Instantly share code, notes, and snippets.

View rhcarlosweb's full-sized avatar
🖖

Rhuan Carlos rhcarlosweb

🖖
View GitHub Profile
/**
* Code that will fit the text to the card of project-grid-item if is only one word vanillajs
*/
const fitText = () => {
const projectGridItems = document.querySelectorAll('.project-grid-item');
projectGridItems.forEach((item) => {
const text = item.querySelector('.title');
// get length of words
const textLength = text.innerText.split(' ').length;
@rhcarlosweb
rhcarlosweb / animations.js
Last active May 24, 2025 17:40
new animations with gsap 3
import gsap from 'gsap'
import ScrollTrigger from 'gsap/ScrollTrigger'
import {SplitText} from 'gsap/SplitText'
import CustomEase from 'gsap/CustomEase'
gsap.registerPlugin(ScrollTrigger)
gsap.registerPlugin(SplitText)
document.addEventListener('DOMContentLoaded', () => {
const animations = {
// of course gulp
const {src, dest, parallel, series, watch} = require('gulp');
// variables
const build = true; // true para compilar e minificar os arquivos - false para não minificar e nem usar babel (performance maior), use true para compilar o projeto final
const jsBuildDir = './assets/dist/js/'; // diretório de destino do bundle.js compilado
const cssBuildDir = './'; // diretório de destino do style.css compilado
// css
const sass = require('gulp-sass');
@rhcarlosweb
rhcarlosweb / playButton.js
Last active July 28, 2021 19:55
Play Button - Video
import gsap from "gsap"
/**
* Pause video if is playing
*/
document.addEventListener("play", function (e) {
const videos = document.getElementsByTagName("video")
for (let i = 0, len = videos.length; i < len; i++) {
if (videos[i] !== e.target) {
videos[i].pause()
@rhcarlosweb
rhcarlosweb / .gitconfig
Last active November 25, 2024 17:24
GitConfig Alias
[alias]
# Shorthand for checkout
co = checkout
# Shorthand for branch
br = branch
# Shorthand for commit
ci = commit
# Shorthand for status
st = status
# Hide file from Git tracking
<?php
function rw_image_resize( $attachment_id, $width, $height, $crop = true )
{
$path = get_attached_file( $attachment_id );
if ( ! file_exists( $path ) )
{
return false;
}
$upload = wp_upload_dir();