Skip to content

Instantly share code, notes, and snippets.

import gsap from 'gsap'
import store from '@/store'
import Events from './Events'
import { lerp } from '@/utils'
const { isDevice, isDesktop } = store.flags
export default new (class {
constructor() {
this.target = 0
import Highway from '@dogstudio/highway'
export default class extends Highway.Renderer {
onEnter() {
this.el = this.wrap.lastElementChild
}
onLeave() {
}
import gsap from 'gsap'
import { qs } from '@/utils'
import { Events } from '@/events'
export default class {
ui = {}
constructor(el = qs('[data-smooth-simple]'), content = null) {
this.el = el
import gsap from 'gsap'
import VirtualScroll from 'virtual-scroll'
import Events from './Events'
// Raf
gsap.ticker.fps(-1)
gsap.ticker.add(tick)
function tick() {
// Create 2 splits, one used to wrap the inner lines with overflow: hidden lines
const outerSplit = new SplitText(title, { type: 'lines' })
const innerSplit = new SplitText(outerSplit.lines, { type: 'lines' })
new gsap.timeline({
onComplete: () => {
// Remove wrappings when complete
innerSplit.revert()
outerSplit.revert()
}
@jesperlandberg
jesperlandberg / Gl.js
Last active January 18, 2020 21:34
The issue I'm having isnt isolated to me, but all the devs ive spoken to that have tried to keep gl objects in sync with scroll on mobile (three.js/Native webgl). Would be cool to solve it hah.
class Gl {
constructor() {
Events.on('tick', this.run) // subscribe to globalraf ticker
}
run = ({ current }) => {
/*
Between routes I remove/add meshes from the scene,
so I'm just updating the position of those currently in the scene
import gsap from 'gsap'
class SimpleDraggable {
constructor() {
this.bindAll()
this.el = document.querySelector('.js-slider-wrap')
this.inner = this.el.querySelector('.js-slider-inner')
this.slides = this.el.querySelectorAll('.js-slide')
export default class extends THREE.Object3D {
init(el) {
this.el = el
this.resize()
}
resize() {
this.rect = this.el.getBoundingClientRect()
import e from '@unseenco/e' // Event emitter, I use my friend Jake's, since its great, but could also use TinyEmitter for example
const Events = new e()
export default Events
const vertex = `
precision mediump float;
attribute vec3 position;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
varying vec2 vUv;