Skip to content

Instantly share code, notes, and snippets.

View FelixLuciano's full-sized avatar
🔭
Discovering

Luciano Felix FelixLuciano

🔭
Discovering
View GitHub Profile
@FelixLuciano
FelixLuciano / horizontal-scrolling.js
Last active April 10, 2023 11:13
Horizontal scrolling
const target = document.querySelector('div')
target.addEventListener('wheel', event => {
const toLeft = event.deltaY < 0 && target.scrollLeft > 0
const toRight = event.deltaY > 0 && target.scrollLeft < target.scrollWidth - target.clientWidth
if (toLeft || toRight) {
event.preventDefault()
event.stopPropagation()
@FelixLuciano
FelixLuciano / subscriber.js
Created April 27, 2020 20:42
Simple subscriber
class Subscriber {
constructor () {
this.subscribers = [];
}
subscribe (subscription) {
this.subscribers.push(subscription);
}
notifyAll (...data) {
this.subscribers.forEach(subscriber => subscriber(...data));
}
@FelixLuciano
FelixLuciano / getAge.js
Last active February 23, 2022 08:47
Get my age
let me = {
birthday: new Date("2000-12-16T19:53:00-02:00"), // YYYY-MM-DDTHH:mm-GMT
get age () {
const livedTimeInMs = Date.now() - this.birthday.getTime()
const ageDate = new Date(livedTimeInMs)
const livedYears = ageDate.getUTCFullYear() - 1970
return livedYears
}
@FelixLuciano
FelixLuciano / My options.js
Last active September 29, 2018 17:19
How many do you have?
new Array(5)
.fill('Option ')
.map((e, i) =>
e + (10 + i).toString(36).toUpperCase()
)
.join('\n')
// But you have no choice