Skip to content

Instantly share code, notes, and snippets.

View sibiraj-s's full-sized avatar
:octocat:
I will eventually reply.

Sibiraj sibiraj-s

:octocat:
I will eventually reply.
View GitHub Profile
@sibiraj-s
sibiraj-s / ReactManualChangeEventTrigger.js
Created April 9, 2019 18:59
React - Manually trigger onChange Event
// Use HTMLInputElement for text input
const nativeTextAreaValueSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value').set
nativeTextAreaValueSetter.call(inputRef, newTextareaValue)
const inputEvent = new Event('input', { bubbles: true })
inputRef.dispatchEvent(inputEvent)
@sibiraj-s
sibiraj-s / verticalScrollPercentage.js
Last active June 23, 2020 19:54
Vertical Scroll Percentage
// include jQuery for this script to work
// or
// replace with vannila javascript where needed
var d = document.documentElement, b = document.body;
var scrollTop = d.scrollTop || b.scrollTop;
var scrollHeight = d.scrollHeight || b.scrollHeight;
var h = document.documentElement,
b = document.body,