This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Subscriber { | |
constructor () { | |
this.subscribers = []; | |
} | |
subscribe (subscription) { | |
this.subscribers.push(subscription); | |
} | |
notifyAll (...data) { | |
this.subscribers.forEach(subscriber => subscriber(...data)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Array(5) | |
.fill('Option ') | |
.map((e, i) => | |
e + (10 + i).toString(36).toUpperCase() | |
) | |
.join('\n') | |
// But you have no choice |
NewerOlder