Skip to content

Instantly share code, notes, and snippets.

View terrysahaidak's full-sized avatar

Terry Sahaidak terrysahaidak

View GitHub Profile
@terrysahaidak
terrysahaidak / index.html
Last active September 11, 2024 19:52
Hermes perf benchmark
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Canvas performance</title>
</head>
<body>
/* eslint-disable react-native/no-inline-styles */
import {Canvas, Group, Rect} from '@shopify/react-native-skia';
import React from 'react';
import {View, Text} from 'react-native';
import RNBootSplash from 'react-native-bootsplash';
import Animated, {
useAnimatedScrollHandler,
useAnimatedStyle,
useDerivedValue,
useSharedValue,
@terrysahaidak
terrysahaidak / SkiaMessage.tsx
Created November 10, 2023 14:35
Skia Message
import React, { useMemo } from 'react';
import { useWindowDimensions } from 'react-native';
import { Canvas, Path, Group, Paragraph, RoundedRect, FitBox, rect, Skia, useFonts } from '@shopify/react-native-skia';
export const TAIL_PATH =
'M3.94273 0V6.12112C4.06491 8.02508 3.83039 9.92913 3.19852 11.7719C2.74874 13.0837 2.12094 14.2964 1.34027 15.4016C1.26825 15.5036 1.20493 15.6101 1.15 15.7201C0.747509 16.0979 0.496094 16.6348 0.496094 17.2304C0.496094 18.3741 1.42328 19.3013 2.56701 19.3013C2.66084 19.3013 2.75322 19.2951 2.84374 19.283C2.92254 19.2764 3.00318 19.2642 3.08557 19.2462C9.1064 17.9284 13.7623 14.5866 15.4498 9.66513C16.5144 6.56026 16.2603 3.22681 14.937 0H3.94273Z';
export const Paragraphs = () => {
const { height, width } = useWindowDimensions();
@terrysahaidak
terrysahaidak / App.tsx
Last active October 26, 2023 17:13
Slow SKIA scroll gesture
import {Canvas, RoundedRect} from '@shopify/react-native-skia';
import React from 'react';
import {StyleSheet, View} from 'react-native';
import {
Gesture,
GestureDetector,
GestureHandlerRootView,
ScrollView,
} from 'react-native-gesture-handler';
import {PanGesture} from 'react-native-gesture-handler/lib/typescript/handlers/gestures/panGesture';
@terrysahaidak
terrysahaidak / ViewControler.swift
Created October 18, 2023 09:09
Insert Space To Scroll View on Drag end
//
// ViewController.swift
// ScrollViewInsertTest
//
// Created by Terry Sahaidak on 18.10.2023.
//
import UIKit
class ViewController: UIViewController, UIScrollViewDelegate {
@terrysahaidak
terrysahaidak / measureAverage.ts
Created August 11, 2023 15:59
measure utility
function createDebounceAverage(
title: string,
phase: string,
delay: number = 100
) {
let values: number[] = [];
let timeout: NodeJS.Timeout;
@terrysahaidak
terrysahaidak / Gallery.tsx
Created April 25, 2023 05:09
Control scroll
const KeyboardAvoidingView = (props) => {
const behavior = props.behavior;
const keyboard = useAnimatedKeyboard();
const insets = useSafeAreaInsets();
const animatedStyle = useAnimatedStyle(() => {
const value = keyboard.height.value - insets.bottom;
if (behavior === 'height') {
import React, {useEffect} from 'react';
import {StyleSheet, View} from 'react-native';
import {map, mapValues} from 'lodash';
function execute(fn) {
const start = global.performance.now();
fn();
const end = global.performance.now() - start;
return end;
import {
Canvas,
LinearGradient,
Path,
useDerivedValue,
useValue,
vec,
Skia,
SkPath,
runTiming,